How can I use nsort operator to lists tags based on a prefix?

I am using the before and after operators and I would like to use tags with the prefix tag:/series/.

Before: <$list filter="[tag[$:/series/]nsort[episode-number]before{!!title}]"/>
After: <$list filter="[tag[$:/series/]nsort[episode-number]after{!!title}]"/>

I have tried:

[prefix:tag[$:/series/]nsort[episode-number]before/after{!!title}]]
/* and */
[tag:prefix[$:/series/]nsort[episode-number]before/after{!!title}]]

I was thinking about using a field to designate which series I want to be filtered:

[tag{!!series-title-tag}nsort[episode-number]before/after{!!title}]]

But before I did that solution, I was wondering if there was a way to use a prefix.

Are you suggesting you have a number of tags with the prefix “$:/series/”?

In your filters you need to start with all tags ands only then filter them for this prefix.

{{{ [tags[]] }}}
{{{ [all[shadows+tiddlers]tags[]] }}}

Then filter on the prefix
{{{ [all[shadows+tiddlers]tags[]prefix[$:/series/]] }}}

This will generate your list of tags with the given prefix.

Yes, I will have multiple $:/series/, but I guess I should have asked how do I determine which take a given tiddler has first.

I really didn’t think this through.

Let’s say Tiddler A is tagged with $:/series/series-1, and Tiddler B is tagged with $:/series/series-2. The idea is to have a {{||template}} tiddler to use before and after operators based on the prefix.

@RedAsset unfortunately I do not follow your requirement very well.

As in my last reply, we found all the tiddler names of tag tiddlers beginning with prefix[$:/series/], note this is not the tiddlers that have those “series tags” tags.

Earlier you use nsort[episode-number] so you are looking for the episode number of each “series tag tiddler” which I do not think is correct.

The best way to build tiddlywiki code, and any other for that matter is to progressively test each step. One way is using the filtered transclusions eg; do this in your wiki;
{{{ [all[shadows+tiddlers]tags[]prefix[$:/series/]] }}}

Another helpful method is using nested list widgets to separate the problem into pieces, and use the variable parameter to keep track of the values eg;

<$list filter="[all[shadows+tiddlers]tags[]prefix[$:/series/]]" variable=series-tag>

</$list>

Now use a list within the above list with another filter and another variable; given we now know that series-tag is available we can use;

<$list filter="[all[shadows+tiddlers]tags[]prefix[$:/series/]]" variable=series-tag>
  <h3>Each series <<series-tag>></h3>
   <$list filter="[<series-tag>tagging[]nsort[episode-number]]" variable=episode-tiddler>
        <<series-tag>> <<episode-tiddler>><br>
    </$list>
</$list>

In the above I assume all the items with the same series tag are episodes within that series and each has a field episode-number containing the number.

What I suggest is find partial solutions and take a step at a time until that part is working, even manually enter the tagname to start, then later use a list to get all tags.

  • Although this seems the longer approach it is not because you fix each issue as it occurs
  • Attempting what you have you have “bitten off more than you can chew”, as soon as your code has two or more problems at once it is ten times harder to resolve.
  • Write shorter bits of code that may only have one problem and solve that first. Then as you move forward you can assemble these into a more complex solution but with working pieces.

Also if you can share test data in a json file, or a link to say a live public tiddlyhost wiki it is MUCH easier for us to help.

Side note: when tagging episodes with a series tag you can make sure they are in the required order using <<tag $:/series/madelorian>> to get the tag pill, and in the dropdow you can drag and drop the order then in your list no need to sort them, just use the default sort, no need to use nsort and set the episode-number field.

You can also use macrocall for the tag macro;
<$macrocall $name=tag tag=<<series-tag>>/>

I was trying to get the prefix for the tag $:/series/ of the <currentTiddler>.

I figure it out based on what you already showed me:

<$list filter="[<currentTiddler>tags[]prefix[$:/series/]]" variable="tag">	
	<$list filter="[tag:<tag>nsort[episode-number]before{!!title}]" variable="last">
		<$link to=<<last>>>❮❮</$link>
	</$list>
	<$list filter="[tag:<tag>nsort[episode-number]after{!!title}]" variable="next">
		<$link to=<<next>>>❯❯</$link>
    </$list>
</$list>

Thanks for the help!

Thanks fore sharing back your working result, it may help others that see this thread.