Hi all,

Recently, someone asked me if it is possible to apply a custom order to the 
tags that are displayed on a tiddler, and I came up with a one-line 
adjustment to the tags ViewTemplate that achieves this:

edit the $:/core/ui/ViewTemplate/tags shadow tiddler and change this line:
<div class="tc-tags-wrapper"><$list 
filter="[all[current]tags[]sort[title]]" template="$:/core/ui/TagTemplate" 
storyview="pop"/></div>
to this:
<div class="tc-tags-wrapper"><$list 
filter="[all[current]tags[]sort[title]sortby{$:/config/TagsOrder}]" 
template="$:/core/ui/TagTemplate" storyview="pop"/></div>

The only change is adding "*sortby{$:/config/TagsOrder}*" to the $list 
filter.

Then, you can enter tag names into $:/config/TagsOrder, and the display of 
tags in the ViewTemplate will show those tags in the order specified.

Note that any tags not included in the config tiddler will be listed first, 
in the default alphanumeric order.  Thus, if the config is empty or 
non-existent, the current TWCore default behavior is retained.

Also, if there are a lot of tags to be listed, you can auto-generate the 
initial contents of $:/config/TagsOrder by using the following $button:

<$vars lf="
">
<$set name="taglist" filter="[tags[]trim[]sort[]addsuffix<lf>join[]]">
<$button> make initial ~TagsOrder
   <$action-setfield $tiddler="$:/config/TagsOrder" text=<<taglist>> />
</$button>
(note that the literal newline following lf=" is important)

This outputs all the current tags, one per line, into the text field of 
$:/config/TagsOrder.  You can then edit the tiddler to 
add/delete/re-arrange the tags to suit your needs.

enjoy,
-e
T

  

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/bedfadea-df81-468b-b852-5e638374671en%40googlegroups.com.

Reply via email to