Folks,

I found my own solution to this challenge using wikitext and macros rather 
than a javascript code change. Perhaps one of our backend developers could 
do better, but this works.

The method is to parse the `<<transclusion>> variable to obtain the first 
value not equal to `<<currentTiddler>>` this may not be true in in some 
circumstances.

In a tiddler tagged $:/tags/Macro
\define pipe() |
\define curlyr() }
\define curlyl() {
\define transcludedTiddler() {{{ 
[<transclusion>removeprefix<curlyl>removesuffix<curlyr>split<pipe>!match<currentTiddler>]
 
}}}

Thus if a "transcluded" tiddler contains 
<<transcludedTiddler>>
it will return the tiddler in which the variable is specified, blank if 
viewing the tiddler directly.

This macro is included with display/intermediate/intermediate 2 and 
final tiddlers in the attached json

*How would we use this?*

   - This allows your code to obtain the name of the tiddler in which it 
   (the code) resides even if that tiddler has being transcluded.
   - This code could access a field in the transcluded tiddler `<$view 
   tiddler=<<transcludedTiddler>> field="fieldname-in-transcluded-tiddler"/>`

I am now working on a way to save in the "first transcluded tiddler" 
`<<transcludedTiddler>>` as callingTiddler such that any transclusion that 
occurs in "first transcluded tiddler" can access "from where it was 
transcluded" via the callingTiddler variable.

Regards
Tony





On Tuesday, December 24, 2019 at 11:01:11 AM UTC+11, TonyM wrote:
>
> Folks,
>
> To cut a long story short I wanted to challenge the group to see if there 
> is a way to extract a tiddler title from an intermediate transclude. 
> attached and Illustrated below;
>
> *Why?*
> Because in a number of new methods I am developing this is a gap in what I 
> can do to simplify the sophisticated (but simple) use of transclusions. 
> Such a solution could make even smarter transclude methods available and 
> reduce the code needed to achieve them, or the need for changes in the core 
> to expand designer options when building wikis.
>
> Here are three tiddlers you can create on Tiddlywiki.com (use JSON file if 
> you want)
>
> Display tiddler
> <h2>Display Tiddler</h2>
> Current Tiddler=<<currentTiddler>><br>
> Display Tiddler=<<storyTiddler>>
>
> ;Simple Transclude (1)
> {{||intermediate}}
>
> ;Transclude with tiddlername (2)
> {{tiddlername||intermediate}}
>
> intermediate tiddler
> \define intermediate() intermediate
> <h2>Intermediate Tiddler</h2>
> Intermediate Tiddler=<<intermediate>><br>
> Current Tiddler=<<currentTiddler>><br>
> Display Tiddler=<<storyTiddler>>
>
> {{||final}}
>
> final tiddler
> <h2>final tiddler</h2>
>
> <h3>How can I find the tiddler name of the intermediate tiddler here?</h3>
> Intermediate Tiddler=<<intermediate>><br>
> Current Tiddler=<<currentTiddler>><br>
> Display Tiddler=<<storyTiddler>>
>
> One solution is to edit the intermediate tiddler as in the example and 
> define a variable based on a literal 
> \define intermediate() intermediate
> as included in the above.
>
> *However*
>
>    - I am looking for a way to avoid editing the intermediate tiddler to 
>    provide its name as a literal
>       - I would accept a programmatic way to store the intermediate name 
>       in intermediate but ideally I would like to avoid editing 
> "intermediate" at 
>       all 
>    - Is there a way to derive this intermediate tiddler title by other 
>    means in final?
>    - What if there was a second intermediate tiddler?
>
> *Hacking*
>
>    - Perhaps there is a way to get/set the last tiddler "doing the 
>    transclude" in "final"  by altering the transclude mechanism?
>    - What if we could somehow determine the full branch used to get to 
>    any level deep
>       - eg (in final) display intermediate final
>       or (in final) display $:/core/ui/Buttons/edit final
>    
> Thanks in advance
> 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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/4861cea6-3503-46c6-b0b0-bc60a78122ee%40googlegroups.com.

Attachment: transcluded-tiddler.bundle.json
Description: application/json

Reply via email to