Syntax error in trying to create wizard

Basic Question

I’m pretty sure what I’m finding is a syntax error and not a fundamental logical one, but feel free to correct me if I’m wrong about that.

I’m trying to add some dynamic navigation links for a linear subset of a mostly non-linear wiki. And while I can do this with the following syntax (hardcoding “Step 2”):

<$list filter="[is[current]tags[]tag[Wizard]]">
  Previous {{!!title}}: <$list filter="[before[Step 2]]"/> ::
  Next {{!!title}}: <$list filter="[after[Step 2]]"/>
</$list>

Whatever I try to make this dynamic, I can’t get it to work. This is the latest broken attempt, although I’ve tried many others:

<$set name="currentStep" value="{{!!title}}">
  <$list filter="[is[current]tags[]tag[Wizard]]">
    Previous {{!!title}}: <$list filter="[before<currentStep>]"/> ::
    Next {{!!title}}: <$list filter="[after<currentStep>]"/>
  </$list>
</$set>

How do I make a working dynamic approach?

Background

In writing some documentation for a proprietary system, I’ve been happily using TW5 and loving the non-linear flow and microcontent. But I have a linear tutorial split up over a number of tiddlers, all tagged “Tutorial”, and I wanted to set up previous/next links for those, based on the Tutorial tiddler’s list field. A simplified version is at Wizard Test — working on it.

I did see some Wizard plugins, but none seemed to do what I want, and I thought it would be a decent way to learn a little more about TW.

So my thought was that I would try to write something that I might eventually turn into a plugin, if I can get it working here. To that end, the thought was that I’d have a tag name (here “Wizard”, but eventually something more like “$:/plugins/me/wizard/Wizard”) and that if another tag – say “Tutorial” – itself was tagged with this, then everything tagged “Tutorial” would be a step of the tutorial, ordered by Tutorial’s list field. There is some additional complexity, as I think it’s possible that one tiddler might serve as part of more than one linear paths, in which case the links will probably look like "Next Tutorial"/"Previous Tutorial" and "Next Foobar"/"Previous Foobar"

Eventually, I would like to make this something automated, using a ViewTemplate. But for the moment, if it was just a macro I could include in the relevant “Tutorial”-tagged tiddlers, I would count it a win.

So the basic question is what’s wrong with my syntax?

I’m also more than open to alternative ideas for how to do this.

Secondary Question

As it stands, the links and the after/before operators are not using the order from the list field, but presumably alphabetic order. Is there a straightforward way to fix this?

How do I make a working dynamic approach?

Try this:

<$set name="currentStep" value={{!!title}}>

Secondary Question
As it stands, the links and the after/before operators are not using the order from the list field, but presumably alphabetic order. Is there a straightforward way to fix this?

Try this:

Previous {{!!title}}: <$list filter="[enlist{!!list}before<currentStep>]"/> ::
Next {{!!title}}: <$list filter="[enlist{!!list}after<currentStep>]"/>

enjoy,
-e

2 Likes

How do I make a working dynamic approach?

Try this:

<$set name="currentStep" value={{!!title}}>

Perfect. I obviously still don’t really understand when and where to use quotation marks in this syntax. Any good reference would be appreciated.

As it stands, the links and the after/before operators are not using the order from the list field, but presumably alphabetic order. Is there a straightforward way to fix this?

Try this:

Previous {{!!title}}: <$list filter="[enlist{!!list}before<currentStep>]"/> ::
Next {{!!title}}: <$list filter="[enlist{!!list}after<currentStep>]"/>

Again, it works exactly right. I had played with enlist, but hadn’t gotten it right, focused mainly on the dynamic link issue.

Thank you very much for your help.

(I’m off now to try to turn this into something more generally useful. I’ll report back if I get something possibly useful to others… Or more likely, I’ll be back asking questions at my next sticking point. Thanks again.)

Edit: updated demo: Wizard Test — working on it

See this tiddler from the doc: https://tiddlywiki.com/#HTML%20in%20WikiText

The sections starting from “Literal Attribute Values” should answer your question :slight_smile:

I obviously still don’t really understand when and where to use quotation marks in this syntax. Any good reference would be appreciated.

See this tiddler from the doc: https://tiddlywiki.com/#HTML%20in%20WikiText

The sections starting from “Literal Attribute Values” should answer your question :slight_smile:

They do very well. Thank you. This community is fantastic!

While this worked very well, when I actually used it, I ran into a problem. I only want to use the list field if it’s actually present, and use the (presumably alphabetic) default ordering of the Tiddlers otherwise. While I can easily use either one, and can even get both with sequential filter steps, I can’t figure out how to combine them to get just the one I need.

I’m pretty sure that this mostly has to do with a combination of my not entirely understanding the filter design – although I’m getting closer – and some blind spot about syntax. I’ve tried many things that I thought should work, and they all fail.

I even went as far as trying to set the list dynamically to the existing default order if there is no list field, but got stuck not knowing how to set the field of a tiddler from inside my ViewTemplate (a macro call, perhaps?); I believe this would not be a very good idea, but would have taken it for a proof of concept. But no dice there. (Any hints welcome!)

Any suggestions?

Try this:

Previous {{!!title}}: <$list filter="[enlist{!!list}] :else[all[]] +[before<currentStep>]"/> ::
Next {{!!title}}: <$list filter="[enlist{!!list}] :else[all[]] +[after<currentStep>]"/>
2 Likes

That fixed it wonderfully. This is coming along nicely, thanks to all the wonderful help here.

One more open issue, which I know how to do, then one new feature, and I think I might have a beta version!

Thank you for all your help!

1 Like