Is it possible to create a template for tabbed tiddlers?

553 views
Skip to first unread message

Jeff Vance

unread,
Mar 18, 2016, 1:24:05 AM3/18/16
to TiddlyWiki
Hey all,

I'm a new user of TW5 (just joined this discussion group).  I've used TW classic a few times in the past and it has been very handy.

I have an idea of how I'd like to manage some notes, and I can do it manually, but it is a kind of a pain.  I'm not sure if it is possible to automate it with templates or macros.  What I would like is to create many tiddlers that consist of 3 tabs:  Summary, Details, Sources. All of these would be containing information on the same topic.

I learned from other guides how to do this manually. I create 3 tiddlers, then use the tabs macro to transclude them into one tiddler (using caption fields to get the tab titles I want). The result is exactly what I want.  However, I'm wondering if there is a way to automate this. I see I can create new tiddlers from templates with buttons. So I was thinking maybe I can create a template tiddler that has the 3 tabs, then create the tabbed content tiddlers, and all the transclusion would be set up automatically.

So any time I create a new tiddler like this, the 3 tabs would need to transclude new unique tiddlers for summary, details, sources. Since the names will have to be unique, it appears some more advanced tricks are necessary to have it transclude different names. Maybe a TextReference can be used to generate the expected tiddler titles to transclude?  Maybe each tabbed tiddler can always be the initial tiddler title, with suffix added like ExampleTiddler_Summary, ExampleTiddler_Details, etc.  

I don't know if this is really the right approach. I'm not sure I quite understand how text references are used so maybe this isn't the right application.  I was also reading some examples of using system tiddlers to determine what to transclude. I feel a little out of my depth at this point since I'm not quite sure how do this.  I appreciate any help.

Jed Carty

unread,
Mar 18, 2016, 3:33:05 AM3/18/16
to TiddlyWiki
I have made some things similar to this and the way I would suggest you create a single viewer tiddler that you can then transclude. Which I think is kind of what you said.

So, you make a form (just some edit-text widgets) and a button that takes the inputs for a title and the summary, details and sources text, then make a button that creates 3 separate tiddlers with a naming convention like you suggest (TiddlerTitle_summary, TiddlerTitle_details, etc.)

Then you make a display tiddler (or a giant macro) you can transclude over and over again with something like this:

\define DisplayTiddler(Name)

!$Name$

<<tabs "[[$Name$_summary]][[$Name$_details]][[$Name$_sources]]>>
\end

Then if you make a set of tiddlers with the title 'Jellybeans' you would put <<DisplayTiddler "Jellybeans">> where you want it displayed and everything should work.

Jeff Vance

unread,
Mar 18, 2016, 7:55:26 PM3/18/16
to TiddlyWiki
Ah, thank you!  This sounds like what I need.  I didn't know about edit-text widgets.  I will give this a try.

Jeff Vance

unread,
Mar 19, 2016, 7:27:11 PM3/19/16
to tiddl...@googlegroups.com
I was playing around with this idea and decided to take a slightly different appraoch. I have something that is almost working, but I'm stuck on 2 issues.

I was thinking it would be more useful to have a tiddler that starts with 1 tab and optionally lets you generate new tabs as you go, adding each tab to the parent tiddler. Looking at the examples, I figured out how to make this work (almost).  Each new tiddler will be given a name to be used as the tab caption, the tiddler itself being named with the tab name as a suffix added to the parent tiddler (in theory...it isn't quite working yet). 

Here is my experiment in progress, and some details:



I created a tiddler "New Tab Form" (see code below), which has 2 edit-text widgets: Tab Title and Text. This form itself has a caption field "+" and it is transcluded as a tab into a view tiddler. So you start out with a single tab that gives you this form with a button to creating another tab:



Title:  <$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTabForm' field='name_temp' placeholder='Tab Title'/>

Text:
<$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTabForm' field='text' placeholder='Tab Text'/>

<$button>Create Tab
<$action-setfield $tiddler="TESTING NEW TAB" text={{$:/state/NewTabForm!!text}} parent={{!!title}} caption={{$:/state/NewTabForm!!name_temp}}/>
<$action-setfield $tiddler='$:/state/NewTabForm' name_temp='' text=''/>
</$button>



I wanted the New Tab Form to be able to access the title of whatever tiddler it is transcluded into. This way it can generate a new tiddler using the name of the parent tiddler and add the tab title as a suffix. So if I start a parent tiddler called "Parent", select the new tab form and say I want a new tab called "Summary", the form will generate a new tiddler called "Parent_Summary", but with a caption field of just "Summary".


So I create a system tiddler $:/state/newtab that simply transludes the form as a template like this:  

{{||New Tab Form}}


Then my parent topic gets all the tabs who's parent field is the title of THIS tiddler (plus the form in the last tab to create even more tabs):

<<tabs "[field:parent[Test Parent Topic]] [[$:/state/newtab]]">>


So this part is basically all working:  

  • The form properly gets the the title of the parent tiddler and assigns it to the parent field of the new tiddler.
  • The filter in the parent properly generates tabs for all the tiddlers who have this assigned as the parent.


So the 2 issues are:

  • I had to hard code the title of the new tiddler (as TESTING NEW TAB above). I couldn't figure out the syntax to have it generate a unique title by combining the {{!!title}} with the !!name_temp field. 
  •  In the parent tiddler, to get the tabs I want, I had to hardcode the filter to search on the exact name of the parent tiddler.  I really want to use !!title as the parent field to filter on. But this doesn't work.  I can't find any examples of using a text reference as an input to filtering on a field (I only see examples of doing this for tags).

I feel like I'm really close to making this work.

Pit.W.

unread,
Mar 19, 2016, 7:46:02 PM3/19/16
to tiddl...@googlegroups.com
I solved this with conditional templates:


<$list filter="[all[current]doctype[this is the type of document that triggers the tabs]]">


<<tabs "[all[tiddlers+system+shadows]tag[$:/tag]]" "$:/some tiddler" "$:/state/demo" "tc-horizontal">>
</$list>



Then I have the tabs, one tiddler per tab. THey look like this: and of course they are tagged : tag[$:/tag]

<$list filter="[all[current]doctype[this is the type of document that triggers the tabs]]">

Something happens here: like a list. The listed tiddlers might for example have a field with the name of the parent tiddler, and the List-filter calles it with {{!!title}}


</$list>
--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/5b79e928-8cfb-42ca-8853-95cd3d6939d6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.




Brian Theado

unread,
Mar 19, 2016, 10:53:06 PM3/19/16
to tiddl...@googlegroups.com
Jeff,

On Sat, Mar 19, 2016 at 7:27 PM, Jeff Vance <vanc...@gmail.com> wrote:
[...] 
I created a tiddler "New Tab Form" (see code below), which has 2 edit-text widgets: Tab Title and Text. This form itself has a caption field "+" and it is transcluded as a tab into a view tiddler. So you start out with a single tab that gives you this form with a button to creating another tab:



Title:  <$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTabForm' field='name_temp' placeholder='Tab Title'/>

Text:
<$edit-text class='tc-edit-texteditor' tiddler='$:/state/NewTabForm' field='text' placeholder='Tab Text'/>

<$button>Create Tab
<$action-setfield $tiddler="TESTING NEW TAB" text={{$:/state/NewTabForm!!text}} parent={{!!title}} caption={{$:/state/NewTabForm!!name_temp}}/>
<$action-setfield $tiddler='$:/state/NewTabForm' name_temp='' text=''/>
</$button>

I tried this and it seemed to work:

<$button>Create Tab
<$list filter="[title[$:/state/NewTabForm]get[name_temp]] +[addprefix[_]addprefix<currentTiddler>]" variable="tabname">
<$action-setfield $tiddler=<<tabname>> text={{$:/state/NewTabForm!!text}} parent={{!!title}} caption={{$:/state/NewTabForm!!name_temp}}/>
<$action-setfield $tiddler='$:/state/NewTabForm' name_temp='' text=''/>
</$list>
</$button>


[...] 

Then my parent topic gets all the tabs who's parent field is the title of THIS tiddler (plus the form in the last tab to create even more tabs):

<<tabs "[field:parent[Test Parent Topic]] [[$:/state/newtab]]">>
 

Try this:

<<tabs "[field:parent<currentTiddler>] [[$:/state/newtab]]">>


Brian

Jeff Vance

unread,
Mar 20, 2016, 12:27:14 AM3/20/16
to TiddlyWiki
Ok, I'm one step closer!  Thanks for the tips, Brian.  I updated the form as you suggested and now it generates new tabs just as I had hoped.  (see updated version).



However, I'm still stuck on using getting the title of the parent tiddler to be used in the filter for tabs.  I tried <currentTiddler>, but it doesn't work.  

Jeff Vance

unread,
Mar 20, 2016, 5:33:28 PM3/20/16
to TiddlyWiki
I tried a few more things, including $macrocall syntax for the tabs macro, thinking that would allow me to use <<currentTiddler>> as the argument to the filter. I was surprised it still doesn't work.

It seems like the issue is how to specify a variable to a filter on a field. I see no examples of this anywhere. There are documented examples of using variables on other filters like on tags and search operators, but there none for the fields operator. Trying the same syntax from those examples doesn't seem to work:  http://tiddlywiki.com/#field%20Operator%20(Examples)

Brian Theado

unread,
Mar 21, 2016, 9:29:03 AM3/21/16
to tiddl...@googlegroups.com

In your tiddlywiki <currentTiddler> worked fine for me. First I cloned your "parent" tiddler to one with a new name and it still had all the tabs from the original (because the tabs filter still has the old parent hard-coded). Then I changed the cloned tiddler to use <currentTiddler> in the filter and only the plus tab was there until I added new tabs. That's the behavior I expect.

What behavior do you see and what do you expect?

--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

Jeff Vance

unread,
Mar 21, 2016, 9:50:17 AM3/21/16
to TiddlyWiki
Ah, you are correct!  I admit, my problem was that I didn't actually save the tiddler to test out the change.  I was looking at the preview of the edit, so I assumed it wasn't working.  But now that I think about it, of course that wouldn't work because while the current tiddler is in draft form, it will have a different title than when it is saved.

This is pretty much what I wanted.  I'll probably tweak this some more to change the ordering of the tabs. Thanks!

Jeff Vance

unread,
Mar 21, 2016, 11:40:12 PM3/21/16
to TiddlyWiki
For those interested, I finished making changes and decided to use this as the final version (link copied again).  I think it works brilliantly now.  I decided I preferred tabbed tiddlers to be titled as "Parent: tab name"  instead of "Parent _tab name", making the derived titles easier to read.  I also changed the filter on the tabs macro so it always sorts the tabs in order by creation time.  Then I made an empty tabbed note as a reusable template and made a button on the side bar to use that for any future tabbed notes.

Thanks again for the help, guys.  Maybe some others will find this useful:

Alex Hough

unread,
Mar 22, 2016, 4:51:41 AM3/22/16
to TiddlyWiki
Thanks Jeff

I think I will find this very useful

Alex

--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
Reply all
Reply to author
Forward
0 new messages