Is it possible to apply tag filters to the story river?

85 views
Skip to first unread message

Jon Light

unread,
Aug 29, 2020, 6:07:59 AM8/29/20
to TiddlyWiki

Hi Noobie here,

I asked my first question yesterday, I think I can better express it in TiddlyWiki terminology.

I would like to be able to create a list of tag-pills such that when I click on one the story river is filtered to only show tiddlers that have that tag.

The project I have in mind breaks down into two parts.

1. Creation of a tiddler that displays a tag-pill for each of my tags. Ideally I would also like to add options to not filter at all and one to filter out tiddlers with tag "Journal".

2. When one of the tag-pills mentioned in 1. is clicked I would like the story river to be filtered so as to show only tiddlers that have the corresponding tags. I might wish to look at only my journal tiddlers in which case I would click the journal tag-pill.

I might be fighting the intended flow of tiddlyWiki here, I note that tag-pills when clicked on offer a drop down offering the user a list of all corresponding tiddlers which they can then visit if they make a selection. In a sense I am trying to create a tiddler where the pull-down is replaced conceptually by a filtered story-river - the user then 'chooses' from the list presented in the story river rather than from a pull down. 

In my first attempt at asking this question I was talking of "views" but now with a little more familiarity I think what I am really asking is...

how can I filter the story river according to a users choice of a single nominated tag?








JD

unread,
Aug 29, 2020, 6:36:33 AM8/29/20
to TiddlyWiki
I can help you with this, but I'd like to know where you'd like this tag list to show? In the sidebar? 

JD

unread,
Aug 29, 2020, 6:51:25 AM8/29/20
to TiddlyWiki
EDIT:

I have some more questions, Jon ^^,

1. Do you want the tag list to have a tree-structure? 

2. While already filtered on a tag, do you want it so that clicking another tagpill will filter it down some more?
    Sample: clicking KENM will filter the storylist to: [!is[system]sort[title]tag[KENM]]
                            then clicking MEME will narrow it some more to [!is[system]sort[title]tag[TAGGER]tag[MEME]] (tiddlers tagged KENM and MEME)

                            ...or will clicking MEME replace the story tiddler to  [!is[system]sort[title]tag[MEME]] ?

btw.. Tiddlywiki can behave however you like ^^,

JD

unread,
Aug 29, 2020, 7:37:49 AM8/29/20
to TiddlyWiki
Anyway, you can begin with this:

Title: PopulateStory
Tags: $:/tags/SideBar
Text:
<$vars limit={{{ [[$:/state/limit]is[tiddler]then{$:/state/limit}else[10]] }}}>

<$range tiddler="$:/state/limit" min="10" max="100" default="10" increment="5"/><br>
limit: <$text text=<<limit>>/> tiddlers

<div class="tc-tags-wrapper">

<$macrocall $name="tag-pill" tag="All tiddlers" element-tag="$button" actions="""<$wikify name="filteredList" text="<$list filter='[!is[system]!sort[modified]limit<limit>]'><$text text='[['/><$text text={{!!title}}/><$text text=']] '/></$list>"><$action-setfield $tiddler="$:/StoryList" list=<<filteredList>>/></$wikify>"""/>
<$macrocall $name="tag-pill" tag="Journal" element-tag="$button" actions="""<$wikify name="filteredList" text="<$list filter='[!is[system]!sort[modified]tag[Journal]limit<limit>]'><$text text='[['/><$text text={{!!title}}/><$text text=']] '/></$list>"><$action-setfield $tiddler="$:/StoryList" list=<<filteredList>>/></$wikify>"""/>
<hr>

<$list filter="[tags[]sort[title]] -Journal" variable="tagItem">
<$macrocall $name="tag-pill" tag=<<tagItem>> element-tag="$button" actions="""<$wikify name="filteredList" text="<$list filter='[!is[system]!sort[modified]tag<tagItem>limit<limit>]'><$text text='[['/><$text text={{!!title}}/><$text text=']] '/></$list>"><$action-setfield $tiddler="$:/StoryList" list=<<filteredList>>/></$wikify>"""/>
</$list>

</div>

</$vars>

Before I go, please be aware this is not the only solution, there are many methods to do this, I think. Also, please be aware listing a lot of tag pills might cause your wiki to lag..! I tried the above code on Tiddlywiki.com itself, which has a lot of tagpills!

-jd

On Saturday, August 29, 2020 at 7:07:59 PM UTC+9, Jon Light wrote:

Jon Light

unread,
Aug 29, 2020, 7:41:32 AM8/29/20
to TiddlyWiki
Hi JD

Thanks very much for responding.

I was thinking of a menu bar at the top for the tag-pills but a side bar might be a good way to do it as well.

The tag list would not be a tree structure, just a linear list with no sense of hierarchy. I have already played around with creating a menu tiddler but lacked the knowledge how to create the necessary code content

So if I had tags

A B C D E F G Journal

Then clicking on A would show all tiddlers that have tag A  in general* I do not need conditionals that involve more than one tag at a time.

My journal tiddlers do not have any additional tags so mutual exclusivity exists.  

*It would be nice to have an extra pill that meant "all except journal" - this would show any tiddler that had at least one of the tags [ABCDEFG] or alternatively did NOT have the tag journal ( courtesy of mutual exclusivity ) but I could live without this. 

Jon Light

unread,
Aug 29, 2020, 7:52:37 AM8/29/20
to TiddlyWiki
Hi JD,

Thanks so much for the solution you posted - straight out of the tin it is pretty much what I wanted and certainly a great starting point for tinkering.
I am glad I asked for help!
I really appreciate your time.
Jon

bimlas

unread,
Aug 29, 2020, 7:57:21 AM8/29/20
to TiddlyWiki
I may not understand your exact purpose, but it seems that the Locator plugin may be useful to you: https://bimlas.gitlab.io/tw5-locator/

Jon Light

unread,
Aug 29, 2020, 8:02:51 AM8/29/20
to TiddlyWiki
Correction - its exactly what I wanted :-) I just needed to play with it a little to realise it ticks all the boxes - Brilliant - many thanks !

JD

unread,
Aug 29, 2020, 9:00:14 AM8/29/20
to TiddlyWiki
Glad this helped! 

Essentially all you needed was for an action to set field:list of tiddler:$:/StoryList to be the result of filter:[tag[TagName]], and yes, there are many paths to produce and present this list, as I'm sure you've found exploring Tiddlywiki ^^,
Reply all
Reply to author
Forward
0 new messages