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/db7634b1-3d9d-492a-884c-568271f13c60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to