chagne sroting for child tidders in TOC??

343 views
Skip to first unread message

HC Haase

unread,
Nov 24, 2016, 5:32:08 AM11/24/16
to TiddlyWiki
Hi
I want most of my TOC to be sorted by title and the child tiddlers under one toc entry/tiddler to be sorted by created date instead (only for this one). Is this possible?

example

a
 aa
 ab
 ac
b
 bb (day1)
 ba (day2)
 bc (day3)
c
 ca
 cb
 cc

Andrew Daum

unread,
Dec 4, 2016, 5:45:54 PM12/4/16
to TiddlyWiki
yes. keep at it!

HC Haase

unread,
Dec 7, 2016, 3:26:54 AM12/7/16
to TiddlyWiki

Den søndag den 4. december 2016 kl. 23.45.54 UTC+1 skrev Andrew Daum:
yes. keep at it!
 
any suggestions ??
 

PMario

unread,
Dec 7, 2016, 4:51:57 AM12/7/16
to TiddlyWiki
On Wednesday, December 7, 2016 at 9:26:54 AM UTC+1, HC Haase wrote:
any suggestions ??

Hi,
IMO with the current TOC macros, that's not possible. There is no generic way to detect which branch should be sorted differently.

But you could create a separate TOC with the "special" sorting and link it from the main TOC. That's the only workaround, that I see at the moment.

-m

PMario

unread,
Dec 7, 2016, 5:22:32 AM12/7/16
to TiddlyWiki
Hi HC,

Which version of the toc macro do you use atm?

I was experimenting with a different TOC approach in Aug. 2014. I did a minimal proof of concept but I didn't extend it, since the existing core version is just good enough for me :)

The mechanism is based on a "parent" field. So every branch can decide, where it wants to be listed. ... But much more experiments would be needed and the configuration isn't convenient atm. 

or

At the moment, we are refactoring the core TOC to implement a protection against an infinite loop. So it may be possible to make the "sort" parameter dynamic. ... I'll have to think about it.

In the mean while, you should go with a workaround.

-mario

Mark S.

unread,
Dec 7, 2016, 11:38:33 AM12/7/16
to TiddlyWiki
You could use the list field of parent "b" to force your sorting on just that level. Of course, you would need to manually update "b" whenever its sub-items changed.

Mark

Mark S.

unread,
Dec 7, 2016, 11:50:51 AM12/7/16
to TiddlyWiki
Idea #2. Create a field called, say, "fuzzy" in just the items you want special sorted and copy the date into it.

Then use this sorting parameter: "sort[title]sort[fuzzy]"

At least in my test, "sort[title]" will be over-ridden by "sort[fuzzy]" whenever "fuzzy" exists.

HTH

Mark

On Thursday, November 24, 2016 at 2:32:08 AM UTC-8, HC Haase wrote:

Riz

unread,
Dec 7, 2016, 12:32:14 PM12/7/16
to TiddlyWiki


Instead of sort[title]sort[fuzzy] if we use sort[title]sort{!!fuzzy} we can set the alternative criteria in the branch that requires it.

eg:
<<toc-selective-expandable TableOfContents sort[title]sort{!!fuzzy}>>  will create a normal TOC sorted by title
Now in a tiddler, say features, we create a field named fuzzy and add the value as "created", children of Features will be sorted in the order of creation date.

Mark S.

unread,
Dec 7, 2016, 1:14:48 PM12/7/16
to TiddlyWiki
Hi Riz,

When I test this, it seems to always sort by title. Did it work on yours?

Have fun,
Mark

Rizwan Ishak

unread,
Dec 7, 2016, 1:17:02 PM12/7/16
to tiddl...@googlegroups.com

I guess it did. I tested on tiddlywiki.com. Under featured, scalability shows up as the first child.


--
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+unsubscribe@googlegroups.com.
To post to this group, send email to tiddl...@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/82e8ff5a-cf7f-43ab-8d04-e954b3cca12f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark S.

unread,
Dec 7, 2016, 2:02:03 PM12/7/16
to TiddlyWiki
I don't understand. "Features" uses the list-links macro.

I also used TiddlyWiki for testing. I used this toc:

<div class="tc-table-of-contents">
<
<toc "Contents" "sort[title]sort{!!fuzzy2}">>
</div>


And then added a fuzzy2 field  to
 


with a value of "created". I then modified the value of the created field SecondThreeThree, moving it a 1000 years into the past. It still floats in the middle, suggesting that it is being sorted by title.


Thanks,
Mark


On Wednesday, December 7, 2016 at 10:17:02 AM UTC-8, Riz wrote:

I guess it did. I tested on tiddlywiki.com. Under featured, scalability shows up as the first child.

On 07-Dec-2016 11:44 PM, "'Mark S.' via TiddlyWiki" <tiddl...@googlegroups.com> wrote:
Hi Riz,

When I test this, it seems to always sort by title. Did it work on yours?

Have fun,
Mark

On Wednesday, December 7, 2016 at 9:32:14 AM UTC-8, Riz wrote:


Instead of sort[title]sort[fuzzy] if we use sort[title]sort{!!fuzzy} we can set the alternative criteria in the branch that requires it.

eg:
<<toc-selective-expandable TableOfContents sort[title]sort{!!fuzzy}>>  will create a normal TOC sorted by title
Now in a tiddler, say features, we create a field named fuzzy and add the value as "created", children of Features will be sorted in the order of creation date.

--
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.

Riz

unread,
Dec 7, 2016, 2:15:30 PM12/7/16
to TiddlyWiki
And then added a fuzzy2 field  to
 

No - just add the fuzzy2 field to SecondThree, ie their parent tiddler. 

Mark S.

unread,
Dec 7, 2016, 2:29:14 PM12/7/16
to TiddlyWiki
That's great!

PMario

unread,
Dec 7, 2016, 2:50:31 PM12/7/16
to TiddlyWiki

That's a good idea!
-m

Philippe Le Toquin

unread,
Dec 8, 2016, 5:11:39 PM12/8/16
to TiddlyWiki
I have a small issue with that method.

I applied it to my TOC. I have a journal tiddler where I want the item sorted so that the last created appears first in the list. I used that line

<<toc-selective-expandable  'TableOfContents' "sort[title]!sort{!!fuzzy}" >>

The field fuzzy is in the journal tiddler and contains created. It does work and my items are listed correctly inside but the issue is that all main title (that are on the same level of journal) also gets their order reverted!

How can I do so that only the content of journal is reverted?

Riz

unread,
Dec 8, 2016, 10:08:42 PM12/8/16
to TiddlyWiki


Sorry Philippe - I was not able to reproduce that error.  Can you post an HTML file with just the issue you raised?

Funnily enough, When I was trying to reproduce it, I realized the limitation of this method. It is not working as I thought it was.

When we give <<toc-selective-expandable  'TableOfContents' "sort[title]!sort{!!fuzzy}" >> , the first criteria -ie, sort[title], is not considered at all. TW5 only tries the second criteria -ie sort{!!fuzzy} and when it cannot find a field named fuzzy, it falls back to the default which is 'sort[]'. This was what was giving the impression that a sort[title] criteria is being worked out

Proof:
1. You can get the same results withe  just <<toc-selective-expandable  'TableOfContents' "sort{!!fuzzy}" >>.
2. Try using <<toc-selective-expandable  'TableOfContents' "!sort{!!fuzzy}" >>
3. You can try using any other sort parameter as the first criteria. Say <<toc-selective-expandable  'TableOfContents' "sort[modified]!sort{!!fuzzy}" >> - it won't work.


Hence this will only work if you are intending to sort by title mainly - but want few exceptions.

hmmm, would have been nice to have the option.
Riz




Mark S.

unread,
Dec 8, 2016, 10:58:09 PM12/8/16
to TiddlyWiki
You can reproduce Philippe's error easily enough. See attached. If you use an inverse, everything gets inversed.

If the macro expected one or more runs, rather than a run sub-set, there might be a way to do it with filter operators.

As it is, I think what you would have to do is create your own sortby field for the Journal entries that have values that are inverse to the created date (like a nine's complement for instance). Or, you could put the sort order you wanted in the Journal tiddler's list field. Either way will involve extra steps.

Mark
sorting.png

Rizwan Ishak

unread,
Dec 8, 2016, 11:00:52 PM12/8/16
to tiddl...@googlegroups.com

This is because of the limitation I mentioned in the previous comment I guess. Because it is not considering sort by title at all
.

Mark S.

unread,
Dec 8, 2016, 11:42:51 PM12/8/16
to TiddlyWiki
Hi Riz,

I think it is sorting by title. When it can't find "fuzzy", then the sort operator collapses to "sort[]", or in this case !sort[]. By default, sort[] sorts by title. The problem is that everything will be sorted either forward or in reverse depending on whether you use the inverse operator. You can't apply the inverse operator only to the fuzzy/created field.

Mark

HC Haase

unread,
Dec 9, 2016, 3:12:39 AM12/9/16
to TiddlyWiki
wow this thread sure got going. Thanks every one.

my use case is exactly the same as  Philippe Le Toquin with the journal sorting. 

well the fuzzy example solves my problem because the fallback title sorting is what i want for top level. However it could be a nice feature to be able to sort by field  like the
sort[title]sort[fuzzy] if we use sort[title]sort{!!fuzzy}

Maybe that could be implementet in the core PMario??? sould that be a github request?

PMario

unread,
Dec 9, 2016, 5:50:19 AM12/9/16
to TiddlyWiki


On Friday, December 9, 2016 at 9:12:39 AM UTC+1, HC Haase wrote:

Maybe that could be implementet in the core PMario??? sould that be a github request?

I did already experiment with a mechanism that reads a field from "branch tags" ...  but I stopped as Riz has come up with his idea, since it's elegant.

I'm still in favor of the idea, to "merge" different TOCs into one tree, where every TOC also can live on its own. IMO thats necessary, to avoid duplications. And I think it will make the code simpler.

-m

PMario

unread,
Dec 9, 2016, 9:02:49 AM12/9/16
to TiddlyWiki, Jetemy Ruston
On Friday, December 9, 2016 at 11:50:19 AM UTC+1, PMario wrote:
On Friday, December 9, 2016 at 9:12:39 AM UTC+1, HC Haase wrote:
Maybe that could be implementet in the core PMario??? sould that be a github request?

I did already experiment with a mechanism that reads a field from "branch tags" ...  but I stopped as Riz has come up with his idea, since it's elegant.

And the code complexity exploded :/
 
I'm still in favor of the idea, to "merge" different TOCs into one tree, where every TOC also can live on its own. IMO thats necessary, to avoid duplications. And I think it will make the code simpler.

I do have a working prototype, that works with a "merge" field. ...
I'm not sure if the name is the right one. May be "include", "toc-include" or even "toc-transclude" would be better. The mechanism that's used is the transclude-widget. .. So may be "toc-transclude" may be the right name.

The structure is as follows: eg:

tiddler: toc-1: <<toc-selective-expandable tag:"root">> .. use standard sorting
tiddler: toc-2: <<toc tag:"journal" sort:"sort[created]">> ..

structure:

 - a .. tagged: root
   - aa .. tagged: a
   - bb .. tagged: a    field:toc-include:toc-2
      - bbb .. tagged bb .. Will not be shown!! toc-include stops the default behaviour
 - x .. tagged: root

The cool thing now is, that bb can link to everything. So if toc-2 contains an other TOC .. fine. If not, the text of the tiddler will be shown. ... There are a lot of new possibilities.

What do you think? ... _and_ should this be part of the core? @Jermolene?

---------------

The actual plan for the core toc refactoring is:

 - Implement the "infinite recursion" protection as in the github PR: 2650
 - Implement TOC "auto selection" depending on "latest tiddler" shown. ... To Be Done

have fun!
mario


Philippe Le Toquin

unread,
Dec 9, 2016, 9:34:10 AM12/9/16
to TiddlyWiki, jeremy...@gmail.com
If I understand you well PMario then it would completely make me happy :)

I thought at first it would complicate the TOC but after rereading it would not affect those who just want a simple TOC.

another example of the great flexibility of TW5 when you know how to program it!

Philippe

Jed Carty

unread,
Dec 9, 2016, 12:38:09 PM12/9/16
to TiddlyWiki
I do have a toc widget that I have been using with TWederation that I am hoping to improve for possible inclusion in the core. It lets you give a template to use and hopefully I can make it so you can easily give much more complex behaviour like different templates at different levels and whatnot. It is still a bit rough and I am not sure when I will be able to finish it but I am hopeful for time to work on this stuff over christmas break.

Mark S.

unread,
Dec 9, 2016, 12:52:52 PM12/9/16
to TiddlyWiki
In line with the general, "Why isn't this documented?" philosophy, I've submitted a pull request documenting the by-branch sort trick to git-hub. Even though it's not perfect in terms of inverse sorts, its probably worth capturing.

PMario

unread,
Dec 13, 2016, 4:12:44 PM12/13/16
to TiddlyWiki
Hi folks,

This post contains an EXPERIMENTAL version of the discussed TOC extensions. It will replace the default core tiddler: $:/core/macros/toc

important tiddlers:

 - aa and bb ... contain the "merge" field parameter
 - test-toc ... shows the full toc tree
 - test-toc-selective-expandable ... same as test-doc but expandable
 - text-???? ... just have a look ;)

Field description:

merge .. tiddler to be transcluded (have a look at aa and bb tiddlers, to see how to use it)
merge-mode ... block / inline (default)

Please test BUT DON'T US IN PRODUCTION TWs yet!
With the new merge-field you can create really crazy TOC combinations.

The macros already contain this PR, which isn't merged yet, but imo it is essential to create crazy TOCs :)

have fun!



toc-merge-experiment.json

Philippe Le Toquin

unread,
Dec 13, 2016, 4:59:09 PM12/13/16
to TiddlyWiki

Probably asking a silly question but as I would really like to test your macro (on a copy of my project :) ) : How do I import it?

PMario

unread,
Dec 13, 2016, 5:48:44 PM12/13/16
to TiddlyWiki
On Tuesday, December 13, 2016 at 10:59:09 PM UTC+1, Philippe Le Toquin wrote:
Probably asking a silly question but as I would really like to test your macro (on a copy of my project :) ) : How do I import it?

Download the .json file and "drag and drop" import it to a TW.

-m

Philippe Le Toquin

unread,
Dec 14, 2016, 8:39:12 AM12/14/16
to TiddlyWiki

Thanks PMario

I have imported the file and tried to apply it to my test TW. It seems to work mainly but...

Here is what I have.

A tiddler called TableOfContents that has the following:

tags: $:/tages/SideBar

<div class="tc-table-of-contents">
<<toc-selective-expandable  'TableOfContents' >>
</div>

field :


I then tagged accordingly the relevant tidders. Since I want to reorder the Journal tiddler I did the following

tag: TableOfContents

<ol >
<<toc "Journal" sort:"!sort[created]">>
</ol>

it also has a field merge with Journal as value.

The result in the tiddler itself is a correct list of all my tiddlers tagged witrh Journal are listed in reverse order of creation....

But there is something strange. in the side bar some of the item under Journal are repeated (see the picture and sorry for the crude black out!)

Is that a problem or am I doing something wrong?


Philippe

PMario

unread,
Dec 14, 2016, 9:15:14 AM12/14/16
to TiddlyWiki
On Wednesday, December 14, 2016 at 2:39:12 PM UTC+1, Philippe Le Toquin wrote:
A tiddler called TableOfContents that has the following:

tags: $:/tages/SideBar

<div class="tc-table-of-contents">
<<toc-selective-expandable  'TableOfContents' >>
</div>

field :


I then tagged accordingly the relevant tidders. Since I want to reorder the Journal tiddler I did the following

tag: TableOfContents

<ol >
<<toc "Journal" sort:"!sort[created]">>
</ol>

it also has a field merge with Journal as value.

Looks good to me.
 
The result in the tiddler itself is a correct list of all my tiddlers tagged witrh Journal are listed in reverse order of creation....

But there is something strange. in the side bar some of the item under Journal are repeated (see the picture and sorry for the crude black out!)

Is that a problem or am I doing something wrong?

That's strange, indeed. Since they are also "toc-selective-" ... Did you save the TW and reload. ... may be there is an refresh problem :/

-m

PMario

unread,
Dec 14, 2016, 9:29:37 AM12/14/16
to TiddlyWiki
It seems, I did ignore my own spec :)

 - a .. tagged: root
   - aa .. tagged: a
   - bb .. tagged: a    field:toc-include:toc-2
      - bbb .. tagged bb .. Will not be shown!! toc-include stops the default behaviour   <--- I knew, there was a reason, why I wrote this

 - x .. tagged: root

As I did play around with it, the restrictions seemed to be not necessary. ... As you found out. .. It is :/

I'll check it.

-m

PMario

unread,
Dec 14, 2016, 9:38:50 AM12/14/16
to TiddlyWiki
try this one. it only contains the toc macros.
-m
toc-merge-experiment-v0.0.2.json

Philippe Le Toquin

unread,
Dec 14, 2016, 4:23:29 PM12/14/16
to TiddlyWiki
yes it had got rid of the duplicated entries.

Thanks :)

PMario

unread,
Dec 15, 2016, 1:59:29 PM12/15/16
to TiddlyWiki
On Wednesday, December 14, 2016 at 10:23:29 PM UTC+1, Philippe Le Toquin wrote:
yes it had got rid of the duplicated entries.

good. .. just be aware, that the toc-expandable doesn't have the changes.
-m
Reply all
Reply to author
Forward
0 new messages