Use a templateTiddler to show fields of parent

78 views
Skip to first unread message

tim...@gmail.com

unread,
Oct 28, 2017, 8:20:55 AM10/28/17
to TiddlyWiki

Hi there

Just trying to get my head around TiddlyWiki for first time and I'd appreciate some guidance / suggestions on this one please:

Is it possible to get a generic 'sub' Tiddler to display the fields of the Tiddler that 'calls' it? Effectively can we use relative references?


e.g.

I'm going to have have multiple Tiddlers, each relating to a single fictional country

On each page I'd like a side bar on the right displaying key info, such as capital, ruler etc (ala Wikipedia)


Rather than set up this right hand panel on every tiddler I thought it would be easier to Transclude a separate tiddler to display this info

I can get this working fine, but I basically end up with a 'sub' tiddler for each country, and while its a bit neater, it doesn't really save me time.


I then thought perhaps I could set some custom fields in each country tiddler
e.g. for the sake of ease lets use a real one, so:

Tiddler Name = UK
field within that called 'capital' with value of 'London'

I figured I could then set up a generic tiddler called sidebarCountry which would say something like:
Capital: {{!!capital}}


Again I can make this work if I put it all in one tiddler or I use a hard coded reference to UK ( {{UK!!capital}} ). But this doesn't solve my problem of not wanting to create a sub tiddler for every country

What I'm hoping for, but can't seem to find, is a way to include a relative reference so the sub tiddler figures out what invoked it
e.g. it might look something like {{..!!capital}}


Is this possible? Am I doing this entirely wrong? I'd welcome suggestions!! :)



I'm using the latest version of TiddlyWiki if that makes a difference


Thanks in advance

Tim

Jed Carty

unread,
Oct 28, 2017, 9:21:34 AM10/28/17
to TiddlyWiki
One quick note: subtiddlers are a completely different thing in tiddlywiki and using sub tiddler in the way you are is going to get very confusing when asking for help. Transcluded tiddler or just tiddler would work in this context and not cause confusion for the people answering your questions.

You are describing templates, so the good news that what you want to do is possible. The biggest problem I see people having with this is conceptual.

To do what you want to do make a tiddler called SomeTemplate and put this in the text field:

Capital: {{!!capital}}

then in the tiddler you want it displayed in put {{||SomeTemplate}}

That should display 

Capital: London

in the UK tiddler you described. But in this form it isn't very useful. Depending on context you probably want to either use view templates or to create a viewer tiddler that will display the content of your other tiddlers using the templates you want. I have some things about templates here http://inmysocks.tiddlyspot.com/#Templates%20in%20WikiText it isn't very complete but it does have some examples you can look at.

Mark S.

unread,
Oct 28, 2017, 9:22:03 AM10/28/17
to TiddlyWiki
I'm confused by the your term "sidebar". Do you mean the existing sidebar with all the tool on the right? Or do you just mean a template tiddler to display country info? I'll assume the latter.

In your template you would have:

Capital: {{!!capital}}
Industry: {{!!industry}}

and then to use it in your country tiddlers, you would use:

{{||template}}

You don't have to type this in all your country tiddlers. Assuming all your country tiddlers have the tag Country, you can tag your template tiddler $:/tags/ViewTemplate with the contents:

<$list filter="[all[current]tag[Country]]">
Capital: {{!!capital}}
Industry: {{!!industry}}
</$list>

Good luck,
Mark

TonyM

unread,
Oct 28, 2017, 9:29:51 AM10/28/17
to TiddlyWiki
Tim,

I do not have time to give an extencive answer however references can have {{Tiddlername!!Fieldname}}

Your desire to show something in the sidebar adds complexity.

Also the currently visible tiddler sets <<currentTiddler>> this gets changed to name each subtiddler title one at a time in a list process unless you set a different variable=name in the list command, allowing currentTiddler to point to the parent.

Any tidder that is included in another can reference the parent tiddlers fields with the correct reference. I expect if you want to display the fields of another tiddler, the target, in the side bar you will have to save the name of the target tiddler somewhere like in a state tiddler the tiddler in the sidebar can use to reference its name and fields.

I susspect everything I have said is correct but may not help. lets see what others say.

Regards
Tony

tim...@gmail.com

unread,
Oct 28, 2017, 10:39:14 AM10/28/17
to TiddlyWiki
Thanks Jed, this is precisely what I was after. I'll take a look at the templates as I can definitely see how conceptually this could be done better.

tim...@gmail.com

unread,
Oct 28, 2017, 10:40:22 AM10/28/17
to TiddlyWiki
Thanks Mark, this is really useful. I'm still trying to wrap my head around all the tags stuff but I can see how it could be very powerful if my puny mind can cope!

tim...@gmail.com

unread,
Oct 28, 2017, 10:42:21 AM10/28/17
to TiddlyWiki
Thanks Tony, I think I confused the issue with my terminology useful of sidebar. I was not refering to the default one with all the option. I think I have the info I need for the time being but many thanks for the response
Reply all
Reply to author
Forward
0 new messages