Autofill Tab Captions, Tooltips and Order fields...across Excised content?

64 views
Skip to first unread message

leeand00

unread,
Apr 20, 2020, 3:31:31 PM4/20/20
to tiddl...@googlegroups.com
When I read something, and I throw it into the wiki, I have a tendency to chunk it into smaller examples...

When I do this I use the "Excise" functionality to split the long text out; it works great but...when I want to split it into tabs the tabs show up with their full titles, and I'd prefer if I didn't have to go to every single tiddler and add a caption, tooltip and order for ever single one; so in looking into this I wrote the following macro so that they are



<$button>
<!-- 1. The title of the current tiddler is obtained into the whichTiddlerTag variable
        at this level that is what you get (unless of course you are in draft mode...in which case,
        I guess you could use !!draft.of instead? )
  -->

<$set name="whichTiddlerTag" value=<
<currentTiddler>> >
<!-- 2. Obtain a count of how many tiddlers have been Excised / tagged with this tiddler's title -->
<$list filter="[tag
<whichTiddlerTag>count[]subtract[1]]">
<!-- 3. A range is generated from 1 to number of excised tiddlers which is now occupying the currentTiddler variable.-->
   <$list filter="[range
<currentTiddler>]">
<!-- 4. For each item in the range from 1 to number of excised tiddlers obtain the tiddler name into whichTiddler based on currentTiddler's 1,2,3,4... -->
      <$set name="whichTiddler" filter="[tag
<whichTiddlerTag>]" select=<<currentTiddler>> >
<!-- 5. whichTiddler contains the name of an individual excised tiddler and currentTiddler is the number in the list. -->
              <$action-setfield $tiddler=<
<whichTiddler>> $field="caption" $value=<<currentTiddler>> />
              <$action-setfield $tiddler=<
<whichTiddler>> $field="tooltip" $value=<<whichTiddler>> />
              <$action-setfield $tiddler=<
<whichTiddler>> $field="order" $value=<<currentTiddler>> />
    </$set>
</$list>
</$list>
</$set>
Set Tab Order, Tooltips and Captions
</$button>

<!-- Displays tabs when we are in draft mode -->
<
<tabs "[tag{!!title}]">>

<!-- Displays tabs when we are in view mode -->
<
<tabs "[tag{!!draft.of}]">>


The script sort of works...not exactly...the first tiddler is always skipped, I'm assuming because the select attribute of $set under 4. wants to start with 0 instead of 1 and I don't know how to decrement it though there are a number of Mathematical operators that have been added to Tiddlywiki since I last looked at it.

But anyway making this work would save massive amounts of time in wikiing, any suggestions on how to make this work?

Also the currentTiddler variable and how it changes makes the code almost unreadable!

leeand00

unread,
Apr 20, 2020, 3:38:24 PM4/20/20
to TiddlyWiki
Okay nevermind; I got it; I found the subtract filter operator works great if you don't mind your tabs starting at 0; and I fixed it in the code above.

leeand00

unread,
Apr 20, 2020, 3:43:53 PM4/20/20
to TiddlyWiki
I noticed something else though with these:


<!-- Displays tabs when we are in draft mode -->
<
<tabs "[tag{!!title}]">>

<!-- Displays tabs when we are in view mode -->
<<tabs "[tag{!!draft.of}]">>

If you try to do it that way, and it's transcluded through another set of tabs, !!title and !!draft.of will interpret it as the tiddler it's transcluded in and not the tiddler itself.
Is there a way around that?

TonyM

unread,
Apr 20, 2020, 9:33:35 PM4/20/20
to TiddlyWiki
Perhaps reshare your fixed code so we can test it on tiddlywiki.com and see if we understand your problem!

Tony

leeand00

unread,
Apr 21, 2020, 3:36:12 PM4/21/20
to TiddlyWiki
Okay...sorry Tony (I think I updated it above, but just in case I did not):

<$button>
<!-- 1. The title of the current tiddler is obtained into the whichTiddlerTag variable
        at this level that is what you get (unless of course you are in draft mode...in which case,
        I guess you could use !!draft.of instead? )
  -->

<$set name="whichTiddlerTag" value=<<currentTiddler>
> >
<$list filter="[tag
<whichTiddlerTag>count[]]">
   <$list filter="[range
<currentTiddler>subtract[1]]">

      <$set name="whichTiddler" filter="[tag
<whichTiddlerTag>]" select=<<currentTiddler>> >
              <$action-setfield $tiddler=<
<whichTiddler>> $field="caption" $value=<<currentTiddler>> />
              <$action-setfield $tiddler=<
<whichTiddler>> $field="tooltip" $value=<<whichTiddler>> />
              <$action-setfield $tiddler=<
<whichTiddler>> $field="order" $value=<<currentTiddler>> />

    </$set>
</$list>
</$list>
</$set>
Set Tab Order, Tooltips and Captions
</$button>

The button defined above will not work (assign caption, tooltip, order) when in draft mode because it can't find anything tagged with the title of the tiddler, so if you press it when you're editing nothing happens.  If you press it when you're not editing it works.

I guess I want to be able to make it work when and when not editing. 

The goal is to make setting the captions (incremental number), tooltips (title caption) and order(incremental number) of the other tiddlers tagged with the currentTiddlers title have these fields so that when they are displayed as tabs they have numbers instead of titles, but you can still see them in the tooltips (also they are ordered, provided you use a filter for the tables like "[tag<currentTiddler>sort[order]".
Reply all
Reply to author
Forward
0 new messages