Hi @Brian_Radspinner
Very nice solution. Thank you.
EDIT i: I added this an as example to Shiraz 3.0.0
Comment i
This is a very clever solution and worth to be added to official documentation, it does as below
- if there is no
class
field, create it and set its value to multicol2
- if tiddler has the
class
field with muticol2
value, then change the value to multicol3
- if tiddler has the
class
field with multicol3
value, then change the value to multicol
- if tiddler has the
class
field with multicol
value, then delete the value (an empty field)
So, I believe there is no need to delete the class, and the below portion of code can be commented out (removed)
<$list filter="[<currentTiddler>class[multicol]]" variable="deleteClass">
<$action-deletefield class />
</$list>
Comment ii
A filter transclusion only returns the first result when it is used as widget attribute value, so the above code can be written as
<$action-setfield $tiddler=<<currentTiddler>> class={{{ [<currentTiddler>!has[class]then[multicol2]] [<currentTiddler>class[multicol2]then[multicol3]][<currentTiddler>class[multicol3]then[multicol]] }}} />
But I like your solution as it is much more semantic.
Comment iii
You may use the toggle
operator and replace the action-setfield
with action-listops
<$action-listops $tiddler=<<currentTiddler>> $field="class" $subfilter="+[toggle[multicol2],[multicol3],[multicol],[]]" />