Using fields from upper tiddlers in multi nested tranclusion

170 views
Skip to first unread message

Andrés Pérez

unread,
Oct 17, 2018, 10:01:40 AM10/17/18
to TiddlyWiki
I think I am doing something unorthodox.

I want to use a template tiddler (call it Arthur) inside another template tiddler (call it Ford).
Arthur will display the transcluded fields 'dolphins' and 'mice'
If I set define field 'dolphins' to "fish" inside of Ford, that template displays it due to Arthur displaying it (and 'mice' remains predictably blank).
If I then transclude Ford as a template inside tiddler Zaphod, but only set 'mice' and not 'dolphins', then 'dolphins' is blank but 'mice' displays the value I set.

Essentially, I want to arrest the transclusion of the 'dolphins' field at Ford without having to specify that in Arthur.

TonyM

unread,
Oct 17, 2018, 8:45:05 PM10/17/18
to TiddlyWiki
Andrés,

To clarify The Tiddler "Alice" contains The Template "Ford" contains The Template "Arthur" 
The Tiddler "Zaphod" contains The Template "Ford" contains The Template "Arthur" ,

Ford has the dolphins field?

I cant fully grasp the example yet.

Regards
Tony

Andrés Pérez

unread,
Oct 18, 2018, 7:05:24 AM10/18/18
to tiddl...@googlegroups.com
Man, that is confusing, ok...

Here are Arthur, Ford, and Zaphod:

Screen Shot 2018-10-18 at 06.55.19.png


Screen Shot 2018-10-18 at 06.54.57.png

Screen Shot 2018-10-18 at 06.54.41.png

Arthur is transcluded in Ford, and Ford is transcluded in Zaphod.

I define 'dolphins' in Ford and 'mice' in Zaphod. Arthur is the only tiddler displaying fields.


From those tiddlers I get this:

Screen Shot 2018-10-18 at 06.55.29.png


but I want this:

Screen Shot 2018-10-18 at 06.56.00.png

Notice that in this last (faked) view, Zaphod is displaying the value of both fields.


I know that the way I just did it is wrong since the transclusion syntax which I used in Arthur implies 'currentTiddler', and Zaphod does not define 'dolphins', but I want to know if any method let's me do it at all.

Jed Carty

unread,
Oct 18, 2018, 7:17:26 AM10/18/18
to TiddlyWiki
I think that you need to describe the desired logic behind the display, not just an example.

bimlas

unread,
Oct 18, 2018, 7:25:34 AM10/18/18
to TiddlyWiki
If I'm right, you want to "evaulate" Arthur in Ford (so "dolphins" field will be set to "fish"), then "push up" this to Zaphod (to set "mice" field to "pan-galactic").

Can you please share this example wiki with us to let us find a way to solve your problem, please?

TonyM

unread,
Oct 18, 2018, 7:50:24 AM10/18/18
to TiddlyWiki
Thats the type of example I could use. Before delving in deeply are you aware of the fact you can access a field in another tiddler, transcluded, in a template or any tiddler by giving both tiddlername!!fieldname eg

{{tiddlername!!fieldname}}

In filters
{tiddlername!!fieldname}

And in some widgets or macros with tiddler=tiddlername
Field=fieldname

These could be fixed litteral names or ones derived from a macro.

Do you see what I am saying?

Regards
Tony

Andrés Pérez

unread,
Oct 18, 2018, 10:07:20 AM10/18/18
to TiddlyWiki
Sure. I thought I had but I can always use more words!

I want to know if it's possible to define a template tiddler which is essentially an overload of another template tiddler to set default values.

I wound up doing it as a macro and have attached a sample TW with both attempts. I was just curious to see how far I can take - ... well, abuse - the wikitext transclusion functionality :)

Andrés Pérez

unread,
Oct 18, 2018, 10:07:35 AM10/18/18
to TiddlyWiki
I am aware, yeah. I know that the way I defined the transclusions in Arthur imply currentTiddler and that by transcluding Arthur as a template.... I am sucking at explaining myself.

I essentially want Arthur to use Ford's value without having to have Arthur explicitly call out Ford. I need Arthur to remain agnostic of any tiddlers which might use it as a template.
Message has been deleted

Andrés Pérez

unread,
Oct 18, 2018, 10:23:34 AM10/18/18
to TiddlyWiki
I have attached a TW which has both the WikiText transclusion attempt at overloading and the macro attempt.
nested-templates.html

Mark S.

unread,
Oct 19, 2018, 10:37:49 AM10/19/18
to TiddlyWiki
You're hoping that the template transclusion will allow OOPS style inheritance. That would be cool. But apparently when using a tiddler as a template, it only uses the *final* (Zaphod) tiddler as the field source.

To make fields work the way you want, you would need to chain at the field level.

In other words, in Ford you would have

In field dolphin: Fish
In field mice: {{Arthur!!mice}}

In Zaphod you would have:

In field dolphin: pan-galactic
In field mice: {{Ford!!mice}}

Then, instead of using "Arthur" as a template, clone Arthur as "Template" and use {{||Template}} in each character tiddler (if you use {{||Arthur}} you may get a recursion error)

I guess what would be needed to automate this process is a button that could take tiddler A and make tiddler B, where are the fields are populated by {{A!!field}}. Then fields in tiddler B could be overwritten with new values as needed.

-- Mark

Reply all
Reply to author
Forward
0 new messages