Conditional styling in list widget?

132 views
Skip to first unread message

HarleyM

unread,
Nov 26, 2017, 2:34:11 AM11/26/17
to TiddlyWiki
Hi,
I'm really new to TiddlyWiki and have what seems to me an embarrassingly simple question (I have a programming background).

Basically, I want to create a list of tiddlers within a tiddler, but to style each list item based on the presence or absence of a tag on that tiddler.

Specifically what I'm trying to do is have a goal tiddler that lists all associated task tiddlers (tagged with task and a tag that links it to the goal)

So far I have:

<$list filter="[!has[draft.of]tag[goal-001]tag[task]sort[title]]">

    <$link to={{!!title}}><$view field="title"/></$link>

</$list>

So far so good, that gives me a list of all the tasks associated with that goal, but what I want to do is to check if each task has a done tag applied and if so strikeout the list item to show that it has been done.

Giving me something like:


Tasks to complete writing goal 1
    Chapter 1
    Chapter 2
    Chapter 3


It seems like it should be incredibly simple, but I can't find how to do it anywhere. I have to admit TW is messing with my head, but I love the concept and I'll get there eventually...

Thanks for any assistance.

Harley

HarleyM

unread,
Nov 26, 2017, 3:31:56 AM11/26/17
to TiddlyWiki
I just noticed that the strikethrough text that I pasted in wasn't rendered. In that example at the bottom Chapter 1 and Chapter 2 should be rendered as struckthrough (illustrating with WikiText formatting):

Tasks to complete writing goal 1
    ~~Chapter 1~~
    ~~Chapter 2~~
    Chapter 3

BJ

unread,
Nov 26, 2017, 5:23:34 AM11/26/17
to TiddlyWiki
this is one way:



<$list filter="[!has[draft.of]tag[goal-001]tag[task]sort[title]]">

<$list filter="[all[current]tag[done]]">
    <$link to={{!!title}}>~~<$view field="title"/>~~</$link>
</$list>
<$list filter="[all[current]!tag[done]]">

    <$link to={{!!title}}><$view field="title"/></$link>
</$list>

</$list>

all the best
BJ

HarleyM

unread,
Nov 27, 2017, 12:38:13 AM11/27/17
to TiddlyWiki
Awesome, thanks BJ.

I wondered if it would require nested filters but I kept getting two of everything. Time to read up on current I think.

Thanks again.
Harley
Reply all
Reply to author
Forward
0 new messages