Jeremy,

I had not seen your reply until now. I found the heading 
in https://tiddlywiki.com/#Transclusion%20in%20WikiText  Generated Widgets 
that hinted at what you suggest. Could this be included in the use of the 
transclude widget as well? (not just `{{ target }}`

By the way the use of StoryTiddler variable helps me identify the 
equivalent of the displayTiddler in the original thread. 

I like your idea of *"making the value of each variable be a list, and 
append the new values at each transclusion"* but there is still value on 
setting a callingTiddler variable, that is changed with each transclusion, 
because it will always provide the last call, which is useful in its own 
right, without interrogating the list(s). This would appear in 
dumpvariables etc... and be somewhat diagnosticly meaningful. 

I see this may require the editing of $:/core/modules/widgets/transclude.js 
so I am not yet qualified to issue a change/pull request.
 
*Here are some thoughts to use this development, to introduce a useful 
macro or widget, at the same time as the above solution is created, because 
the proposal requires something like this anyway. Basically exposing a 
common logical function to users.*

To build your suggested list perhaps we can introduce a list "push and pop" 
widget(s) or macro and use that. Since such a push and pop could be useful 
elsewhere. If you are not familiar with push and pop I mean a macro or 
widget such as 
<<push "field/textreference" "listitem" "delimiter">>
that adds list item at the end (titles delimited Space for fields) newline 
for text

A default of 
<<push "field/textreference">>
would push the current tiddler title onto the end of the list in 
textreference


<<pop "textreference">>
Removes the last item from text reference regardless of what it is.

   - This could allow the use of recursive loops inside transclusions ie 
   TOC equivalent. 
   - It could refuse to push a tiddler title already in the "list" to stop 
   loops
   - It is a basic form of append, and can also be used for log solutions.


This could be used to push and pop a tag, list field entry, datatiddler 
items or build a branch (field) whilst iterating a TOC and more. 

Eg a recursive process could build a branch describing each tiddler by the 
full path to it, and save this branch/path in each tiddler, or in a data 
tiddler. This would allow a complex hierarchy to be saved for later, even 
when the source tiddlers change their relationships.

There are other possibilities that I will leave out for brevity.

Tony




On Saturday, November 2, 2019 at 10:41:11 PM UTC+11, Jeremy Ruston wrote:
>
> Hi Tony
>
> We could extend the transclude widget so that it sets a 
> “currentTransclusionTitle” variable with the name of the tiddler that it is 
> transcluding. We’d actually also need to set variables 
> currentTransclusionField, currentTransclusionIndex and 
> currentTransclusionSubtiddler to capture all the attributes of the 
> transclusion.
>
> Then, in your example below, the tiddler “Second” would be able to obtain 
> the name of the tiddler from which it was transcluded.
>
> A potential limitation is that each successive transclusion would 
> overwrite the values of those variables. We could work around that by 
> making the value of each variable be a list, and append the new values at 
> each transclusion.
>
> Does that make sense, and would it do what your after?
>
> Finally, a small point, but you’ve got this construction:
>
> <$set name="callingTiddler" value={{{ [<currentTiddler>] }}} >
>
> It could be written more concisely as:
>
> <$set name="callingTiddler" value=<<currentTiddler>>>
>
> Best wishes
>
> Jeremy
>
> On 2 Nov 2019, at 06:17, TonyM <[email protected] <javascript:>> wrote:
>
> Folks,
>
> A solution was found for this specific use case, before posting, but the 
> Question still could do with an answer
>
>    - Use the <<storyTiddler>> variable to find the "DisplayTiddler" 
>    regardless of the number of transclusions.
>
>
> A reoccurring confusion of mine occurs trying to implement the following 
> with a define rather than a set, is it possible?
> <$set name="callingTiddler" value={{{ [<currentTiddler>] }}} >
> 1st: <br>
> {{tiddlername||Second}}
> </$set> 
> The value <<callingTiddler>> will be available in all nested transclusions.
>
> The problem with this is you always need to close the set widget. This 
> means every time you edit or add something to the tiddler you have to make 
> sure changes that need it are inside the set.
>
> Is there a way to 
> \define callingTiddler() something
> to achieve the same result?
>
> The problem is whatever you place in a macro definition gets evaluated 
> when its displayed not before 
>
> Of course I can use;
> \define callingTiddler() actual tiddlername
> With a literal tiddler name but then each tiddler needs a unique setting 
> and you can't "import variables", make it global or any other method I can 
> think of
>
> *Why?*
>
>    - I really want an answer to support a range of methods
>    - You can see in the above the use of `{{tiddlername||Second}}`! here 
>    I can transclude Second with tiddlername acting as a parameter for 
> "Second" 
>    to use, but I still want access to the callingTiddler in that transclusion 
>    and other nested in "Second"
>
> *I would love global a method to capture for subsequent use in 
> transclusions the current "Display Tiddler"/callingTiddler - ie the one on 
> the screen before transclusion, but as many of you know the currentTiddler 
> changes according to context so it can't be used.*
>
> Note: I went looking in the tiddler $:/config/ui/ViewTemplate to see how I 
> may set a displayTiddler value only to find the variable storyTiddler which 
> is functionally what I need. Though it does nothing to help me define a 
> variable that will store the current tiddler indefinitely.
>
> Regards
> Tony
>
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/tiddlywiki/79a27e56-918e-4431-9c12-f7cc83ff3e1c%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/tiddlywiki/79a27e56-918e-4431-9c12-f7cc83ff3e1c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/130819b8-a9b2-49ca-980e-2252b761714f%40googlegroups.com.

Reply via email to