I have built a system where I constitute a whole article from parts, recursively. I use two templates for this, one for the nodes and one for the leaf.
Each part a a part number (“partnum” field). If the tiddler is transcluded within an an other part, I want to display tgat partnum. But not if it is not (that is, the tiddler is open in the main river story).
How can I check for that?
On looking for a solution, I saw there might be another approach with embedded story, but as I’m not interested by tweaking the parts, I shall keep my mechanism. But I could use the story mechanism to build the complete story. A kind of edit mode for the whole article, or part of it. Has anybody used it likewise? Would it be a god idea? Any hint about going that way?
@pmario Tried it. First, a little problem: how to call qualify via transclude when nowhere in the doc is given the name of the argument of qualify. YATFRD (yet another time for revising documentation as new possibilities ask for more complete docs).
So I tried this:
* qualify via transclude: <<transclude variable=qualify tiddler=`$(currentTiddler)$`>> FOR <<currentTiddler>>
* qualify direct: <<qualify `$(currentTiddler)$`>> FOR <<currentTiddler>>
* transclusion: <<transclusion>>
which can render something like below:
qualify via transclude: FOR DAT::1.1 Documents normatifs
qualify direct: $(currentTiddler)$-242409137 FOR DAT::1.1 Documents normatifs
Should for this tiddler hard code something about the qualify result having exactly the number 907970045 in its value? I have a lot of parts, this seems clumsy. And could this number vary? Isn’t it a generic way to check for this?
Depending on how your templates are set up, you could compare the currentTiddler and storyTiddler variables. If they don’t match, then you’d have a case of transclusion.
This does depend on the currentTiddler specifying the current part correctly, though.
I did add links to the macro tiddler and the examples tiddler to the link text (also in my OP)
qualify-macro is used to make the string shorter, but technically it is the “transclusion-variable-string” converted to a “number”.
I’m sorry if my comment was harsh but –
I think you give yourself a harder time as necessary, by using all the latest core features at once.
In general I think it’s a good thing to use the latests features! – But it also is a bit of a “mixed blessing”, if something does not work out as expected.
If that happens, it’s not really clear, if the new and “ambitious code” has a problem, or if using the “new feature” has a problem.
I do not have a general answer. I can only say, what works for me. I try to “keep it simple” and break it down into “smaller pieces”.
@pmario I think I’m going to let it loose on the \procedure stuff. This is along what you say. I can’t see any benefits of it for macro to be called on action gadget. They are nice for macros display. But as I also saw, this means that any rendering should be deferred to a template because being called by an action macro would mean no arguments for these.
You were not harsh, but true. I do appreciate being frank.
I am yet to explore the new conditional structure and how it works with the rest of tiddlywiki scripting but it is importiant to remember it is easy to use the same filter within standard filters like in the $list widget.