Overly technical background

Mohammad,

On tiddlywiki.com we can see a number of toc macros mentioned
toc, toc-expandable, toc-selective-expandable, toc-tabbed-internal-nav and 
toc-tabbed-external-nav

Advanced Search for one that interests you such as toc-selective-expandable 
and you will find it in the shadow $:/core/macros/toc

Open $:/core/macros/toc in edit mode and you can see how it works


```
\define toc-selective-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-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
```


;Which you work through carefully and you find it "calls"  
`<<toc-selective-expandable-empty-message>>` If there is nothing to process 
which then calls toc-linked-selective-expandable-body
;Or the above calls toc-unlinked-selective-expandable-body if there is some 
thing


```
\define toc-linked-selective-expandable-body(tag,sort:"",itemClassFilter:" 
",exclude,path)
<$set name="toc-state" value=<<qualify 
"""$:/state/toc$path$-$(currentTiddler)$""">>>
  <$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[]limit[1]]" variable="ignore" 
emptyMessage="<$button 
class='tc-btn-invisible'>{{$:/core/images/blank}}</$button>">
          <$reveal type="nomatch" state=<<toc-state>> text="open">
            <$button set=<<toc-state>> setTo="open" class="tc-btn-invisible 
tc-popup-keep">
              {{$:/core/images/right-arrow}}
            </$button>
          </$reveal>
          <$reveal type="match" state=<<toc-state>> text="open">
            <$button set=<<toc-state>> setTo="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="open">
        <$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> 
sort="""$sort$""" itemClassFilter="""$itemClassFilter$""" 
exclude="""$exclude$""" path="""$path$"""/>
      </$reveal>
    </li>
  </$set>
</$set>
\end
```



;Now notice how this in turn calls toc-selective-expandable!


;toc-unlinked-selective-expandable-body

```
\define 
toc-unlinked-selective-expandable-body(tag,sort:"",itemClassFilter:" 
",exclude,path)
<$set name="toc-state" value=<<qualify 
"""$:/state/toc$path$-$(currentTiddler)$""">>>
  <$set name="toc-item-class" filter="""$itemClassFilter$""" 
emptyValue="toc-item" value="toc-item-selected">
    <li class=<<toc-item-class>>>
      <$list filter="[all[current]tagging[]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="open">
          <$button set=<<toc-state>> setTo="open" class="tc-btn-invisible 
tc-popup-keep">
            {{$:/core/images/right-arrow}}
            <<toc-caption>>
          </$button>
        </$reveal>
        <$reveal type="match" state=<<toc-state>> text="open">
          <$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="open">
        <$macrocall $name="""toc-selective-expandable""" 
tag=<<currentTiddler>> sort="""$sort$""" 
itemClassFilter="""$itemClassFilter$""" exclude="""$exclude$""" 
path="""$path$"""/>
      </$reveal>
    </li>
  </$set>
</$set>
\end
```



Now notice how this in turn calls toc-selective-expandable!

So lets make this simpler

toc-selective-expandable > toc-linked-selective-expandable-body (Via empty) 
> Calls the first macro "toc-selective-expandable"
                         Or
                         > toc-unlinked-selective-expandable-body > Calls 
the first macro "toc-selective-expandable"


So the first macro is repeatedly called until very part of the Tree is 
visited.

Regards
Tony

On Tuesday, August 7, 2018 at 6:56:11 PM UTC+10, TonyM wrote:
>
> Mohammad,
>
> Consider this psydo code
>
> Here is some psudo code
>
> \define first-level(roottag)
> Call/list <<remaining-levels tiddler>> for every tiddler tagged with root-
> tag
>   Sort the first level by caption (Children)
> \end
>
>
> \define remaining-levels(tag)
> Call/list <<remaining-levels tiddler>>
>   by manual order in list filed for every tiddler tagged with $tag$
>   (grandchildren and greatgrandchildren etc..)
> \end
>
>
> and call with 
> <<first-level roottag>>
>
> I am sure you have the skills to fill this out, but don't hesitate to ask.
>
> If you want to stop the TOC going more than three levels deep just rename 
> remaining-levels to children, and have it call a new macro called grand 
> children which does not call any other macro.
>  
> Regards
>
>
> Tony
>
> On Tuesday, August 7, 2018 at 6:00:05 PM UTC+10, Mohammad wrote:
>>
>> Tony,
>>  Would you please explain a little more! I did not understand how it can 
>> be done!
>>
>> Best
>> Mohammad
>>
>> On Tuesday, August 7, 2018 at 6:17:57 AM UTC+4:30, TonyM wrote:
>>>
>>> Mohammad,
>>>
>>> Build your own toc macros with the first level sorted as desired, then 
>>> second and subsequent levels with no sorting, and the recursive process 
>>> mentioned by myself recently.
>>>
>>> I have being looking for some example code I have but have not found it 
>>> yet.
>>>
>>> Regards
>>> Tony
>>>
>>> On Tuesday, August 7, 2018 at 4:43:36 AM UTC+10, Mohammad wrote:
>>>>
>>>> How is it possible to use toc-selective-expandable  and 
>>>>
>>>>    - Sort the first level by caption
>>>>    - The second and third level by manual order in list filed
>>>>
>>>>
>>>> *Mohammad*
>>>>
>>>

-- 
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/88ff10ac-2bcc-4a58-b11b-fec7f2a5ef59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to