Discussion:
[tw5] toc-selective-expandable macro sort option
(too old to reply)
Mohammad
2018-08-06 18:43:36 UTC
Permalink
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/2ed9788d-f069-413a-bf18-2485d3e54c85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TonyM
2018-08-07 01:47:57 UTC
Permalink
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
Post by Mohammad
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/60e6909b-727d-44f6-ada4-4c50c02823cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mohammad
2018-08-07 08:00:05 UTC
Permalink
Tony,
Would you please explain a little more! I did not understand how it can be
done!

Best
Mohammad
Post by TonyM
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
Post by Mohammad
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/83df9f88-0be6-40a6-a5a4-97b26416e375%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TonyM
2018-08-07 08:56:11 UTC
Permalink
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
Post by Mohammad
Tony,
Would you please explain a little more! I did not understand how it can
be done!
Best
Mohammad
Post by TonyM
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
Post by Mohammad
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/3bae1b6e-b474-44e0-95d8-69af183f5e80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
TonyM
2018-08-07 08:58:54 UTC
Permalink
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
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
Post by Mohammad
Tony,
Would you please explain a little more! I did not understand how it can
be done!
Best
Mohammad
Post by TonyM
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
Post by Mohammad
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/88ff10ac-2bcc-4a58-b11b-fec7f2a5ef59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mohammad
2018-08-07 09:16:51 UTC
Permalink
Thanks Tony!
So it seems I should go inside those macros to understand what going ob
there!
By the way the standard macro toc-selective-expandable seems to get a sort
parameter which apply to all root and childern!


<div class="tc-table-of-contents">
<<toc-selective-expandable "slideshow" "sort[caption]">>
</div>

So, it seems I cannot use the default macro

/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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/4143585b-28d6-4dd6-afb3-0541fd23f4df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
PMario
2018-08-07 10:06:09 UTC
Permalink
Post by Mohammad
Thanks Tony!
So it seems I should go inside those macros to understand what going ob
there!
By the way the standard macro toc-selective-expandable seems to get a
sort parameter which apply to all root and childern!
<div class="tc-table-of-contents">
<<toc-selective-expandable "slideshow" "sort[caption]">>
</div>
So, it seems I cannot use the default macro
That's right. .. The default TOC macros cover about 80% of usecases. The
other 20% are highly user specific and much harder to implement in a
generic way. ... That's why they may be plugins .. .

- I did 1 plugin, which is called: tocP ... "parent based" TOC. see:
https://wikilabs.github.io/editions/tocP/ ... which *probably won't work
for your usecase*

- I also did an experimental version named: "toc merge" which atm
overwrites the "core toc macros". That's why it is still an experiment. You
can learn more here in the group
<https://groups.google.com/forum/#!searchin/tiddlywiki/toc$20merge$20pmario|sort:date/tiddlywiki/55zEWhzGF3c/KJsQUnFgCgAJ>.
This thread also contains an attachment, that you can use for testing.

This one may be a starting point for your usecase. ... It actually could do
what you want. ... but ... it still needs a lot of manual adjustments,
which may be too hard for "end users" ... It should be OK for advanced
users. .....

There is no docs, so have a closer look at the linked threads. ... all of
them!

have fun!
mario
--
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 ***@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/2c264c54-28be-489e-8951-286b9fb04756%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mohammad
2018-08-07 12:56:36 UTC
Permalink
Thanks Mario!
Good stuff!

Mohammad
Post by PMario
Post by Mohammad
Thanks Tony!
So it seems I should go inside those macros to understand what going ob
there!
By the way the standard macro toc-selective-expandable seems to get a
sort parameter which apply to all root and childern!
<div class="tc-table-of-contents">
<<toc-selective-expandable "slideshow" "sort[caption]">>
</div>
So, it seems I cannot use the default macro
That's right. .. The default TOC macros cover about 80% of usecases. The
other 20% are highly user specific and much harder to implement in a
generic way. ... That's why they may be plugins .. .
https://wikilabs.github.io/editions/tocP/ ... which *probably won't work
for your usecase*
- I also did an experimental version named: "toc merge" which atm
overwrites the "core toc macros". That's why it is still an experiment. You
can learn more here in the group
<https://groups.google.com/forum/#!searchin/tiddlywiki/toc$20merge$20pmario%7Csort:date/tiddlywiki/55zEWhzGF3c/KJsQUnFgCgAJ>.
This thread also contains an attachment, that you can use for testing.
This one may be a starting point for your usecase. ... It actually could
do what you want. ... but ... it still needs a lot of manual adjustments,
which may be too hard for "end users" ... It should be OK for advanced
users. .....
There is no docs, so have a closer look at the linked threads. ... all of
them!
have fun!
mario
--
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 ***@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/19f34f2d-8a15-4568-a326-d92507e16095%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
DemoniWaari
2018-08-08 07:33:47 UTC
Permalink
Hi Mohammad,

I had a similar problem as you but in my case my first level is manual and
third level is by creation date and this method works fine. I have not
tried this for your case though. What you need to do it sort your TOC
according to a field, e.g., <<toc-selective-expandable 'Contents'
sort{!!sorting}>> and make a field called sorting in the Contents tiddler
and write caption there. This will sort the first level by caption. Then on
the second and third level tiddlers you will make *both *sorting and list fields.
In the sorting field you will type list (now it references to the list
field) and in the list field you will write the order in manually.

Though I did notice that if I put this TOC in the side bar, my first level
manual sorting does *not *look the same as in the tiddler itself and there
it is sorted by title.
Post by Mohammad
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/a93a28ca-b216-4471-8d2f-0e078edaffd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Mohammad
2018-08-08 11:17:57 UTC
Permalink
Good trick!
Unfortunately did not work for me! What I did now is I removed the caption
from second and third level and only used in the first level now
toc-selective-expandable works for me! but if you use in second level in
any child a caption, then again it confuses and the sorted result is wrong!


*Mohammad*
Post by DemoniWaari
Hi Mohammad,
I had a similar problem as you but in my case my first level is manual
and third level is by creation date and this method works fine. I have not
tried this for your case though. What you need to do it sort your TOC
according to a field, e.g., <<toc-selective-expandable 'Contents'
sort{!!sorting}>> and make a field called sorting in the Contents tiddler
and write caption there. This will sort the first level by caption. Then
on the second and third level tiddlers you will make *both *sorting and list
fields. In the sorting field you will type list (now it references to the
list field) and in the list field you will write the order in manually.
Though I did notice that if I put this TOC in the side bar, my first level
manual sorting does *not *look the same as in the tiddler itself and
there it is sorted by title.
Post by Mohammad
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 tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/edb40697-9ff5-43a8-a500-4d67ab448c66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...