ps In my own filter I needed
"[all[current]has[caption]get[caption]]
[all[current]!has[caption]get[title]] +[sort[]]"
Regards
Tony
On Thursday, September 13, 2018 at 10:48:01 AM UTC+10, TonyM wrote:
>
> Nice Filter!
>
> On Thursday, September 13, 2018 at 3:18:12 AM UTC+10, Mark S. wrote:
>>
>> It sounds like you have things mostly sorted out.
>>
>> A filter like this might allow you to sort by caption or title (whichever
>> is present):
>>
>> [has[caption]get[caption]] [!has[caption]get[title]] +[sort[]]
>>
>> Just remember, that if you use caption then there might be more than one
>> tiddler that uses that caption and you can't form a standard link based on
>> the caption name.
>>
>> Good luck!
>> -- Mark
>>
>> On Tuesday, September 11, 2018 at 6:31:21 PM UTC-7, S H Chang wrote:
>>>
>>> I should have scrutinised my code before posting here. There was a
>>> mistake in <<toc-linked-selective-single-expandable-body>>; it didn't have
>>> the list for "empty" children. I've also realised that it should be
>>> !tag[Log]!visibility[hidden] instead. I've added that to the macro so now
>>> it looks like this:
>>>
>>> \define toc-linked-selective-single-expandable-body(tag,sort:"",
>>> itemClassFilter:" ",exclude,path)
>>> <$set name="toc-state" value=<<qualify """$:/state/toc/$tag$""">>>
>>> <$set name="toc-item-class" filter="""$itemClassFilter$""" emptyValue=
>>> "toc-item" value="toc-item-selected" >
>>> <li class=<<toc-item-class>>>
>>> <$link>
>>> <$list filter=
>>> "[all[current]tagging[]!visibility[hidden]!tag[Log]limit[1]]" variable=
>>> "ignore" emptyMessage="<$button
>>> class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
>>> <$reveal type="nomatch" state=<<toc-state>> text=<<
>>> currentTiddler>>>
>>> <$button set=<<toc-state>> setTo=<<currentTiddler>>
>>> class="tc-btn-invisible
>>> tc-popup-keep">
>>> {{$:/core/images/right-arrow}}
>>> </$button>
>>> </$reveal>
>>> <$reveal type="match" state=<<toc-state>> text=<<
>>> currentTiddler>>>
>>> <$button set=<<toc-state>> setTo="x-all-close"
>>> class="tc-btn-invisible
>>> tc-popup-keep">
>>> {{$:/core/images/down-arrow}}
>>> </$button>
>>> </$reveal>
>>> </$list>
>>> <<toc-caption>>
>>> </$link>
>>> <$reveal type="match" state=<<toc-state>> text=<<currentTiddler>>>
>>> <$macrocall $name="toc-selective-single-expandable" tag=<<
>>> currentTiddler>> sort="""$sort$""" itemClassFilter=
>>> """$itemClassFilter$""" exclude="""$exclude$""" path="""$path$"""/>
>>> </$reveal>
>>> </li>
>>> </$set>
>>> </$set>
>>> \end
>>>
>>> \define toc-unlinked-selective-single-expandable-body(tag,sort:"",
>>> itemClassFilter:" ",exclude,path)
>>> <$set name="toc-state" value=<<qualify """$:/state/toc/$tag$""">>>
>>> <$set name="toc-item-class" filter="""$itemClassFilter$""" emptyValue=
>>> "toc-item" value="toc-item-selected">
>>> <li class=<<toc-item-class>>>
>>> <$list filter=
>>> "[all[current]tagging[]!visibility[hidden]!tag[Log]limit[1]]" variable=
>>> "ignore" emptyMessage="<$button
>>> class='tc-btn-invisible'>{{$:/core/images/blank}}</$button> <$view
>>> field='caption'><$view field='title'/></$view>">
>>> <$reveal type="nomatch" state=<<toc-state>> text=<<
>>> currentTiddler>>>
>>> <$button set=<<toc-state>> setTo=<<currentTiddler>>
>>> class="tc-btn-invisible
>>> tc-popup-keep">
>>> {{$:/core/images/right-arrow}}
>>> <<toc-caption>>
>>> </$button>
>>> </$reveal>
>>> <$reveal type="match" state=<<toc-state>> text=<<currentTiddler
>>> >>>
>>> <$button set=<<toc-state>> setTo="close" class="tc-btn-invisible
>>> tc-popup-keep">
>>> {{$:/core/images/down-arrow}}
>>> <<toc-caption>>
>>> </$button>
>>> </$reveal>
>>> </$list>
>>> <$reveal type="match" state=<<toc-state>> text=<<currentTiddler>>>
>>> <$macrocall $name="""toc-selective-single-expandable"""
>>> tag=<<currentTiddler>> sort="""$sort$"""
>>> itemClassFilter="""$itemClassFilter$""" exclude="""$exclude$"""
>>> path="""$path$"""/>
>>> </$reveal>
>>> </li>
>>> </$set>
>>> </$set>
>>> \end
>>>
>>> \define toc-selective-single-expandable-empty-message()
>>> <<toc-linked-selective-single-expandable-body tag:"""$(tag)$""" sort:
>>> """$(sort)$""" itemClassFilter:"""$(itemClassFilter)$""" exclude:
>>> """$(excluded)$""" path:"""$(path)$""">>
>>> \end
>>>
>>> \define toc-selective-single-expandable(tag,sort:"",itemClassFilter,
>>> exclude,path)
>>> <$vars tag="""$tag$""" sort="""$sort$""" itemClassFilter=
>>> """$itemClassFilter$""" excluded="""$exclude$ -[[$tag$]]""" path=
>>> """$path$/$tag$""">
>>> <ol class="tc-toc toc-selective-expandable">
>>> <$list filter="""[all[shadows+tiddlers]tag[$tag$]!has[draft.of]$sort$]
>>> -[[$tag$]] $exclude$""">
>>> <$list filter="[all[current]toc-link[no]]" variable="ignore"
>>> emptyMessage=<<toc-selective-single-expandable-empty-message>> >
>>> <$macrocall $name=toc-unlinked-selective-expandable-body tag=
>>> """$tag$""" sort="""$sort$""" itemClassFilter="""$itemClassFilter$"""
>>> exclude=<<excluded>> path=<<path>> >
>>> </$list>
>>> </$list>
>>> </ol>
>>> </$vars>
>>> \end
>>>
>>> Hopefully it might help someone out in future.
>>>
>>> As for the second question I have, I suppose it's not possible. What I
>>> had in mind when I posted was that the toc would sort alphabetically, but
>>> it would use the caption's value if there were one, else the title. I've
>>> decided to just use the list field for all the parents.
>>>
>>
--
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 post to this group, send email to [email protected].
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/c0991e33-f3b8-4cca-9fee-c09b8519cbc2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.