List sorting hierarchy syntax help

140 views
Skip to first unread message

Scott Kingery

unread,
Jun 24, 2018, 12:58:00 AM6/24/18
to TiddlyWiki
Here's what I want to do...

I have a tiddlers that represent restaurants and stores. So those tiddlers will be like:

Title: name of restaurant or store
Location is a field that indicates where the restaurant is located
Blurb is a field that is some info about the place

There is a subtopic field that is either Restaurant or Store.

My goal is to have another tiddler that had a title of a location and lists all the restaurants or stores in that location.

I want it to group the restaurants and stores together. Like this:

Restaurant
   
Joes Bar
   
Mikes Burgers
Shops
   
Toys n More
   
Wizard of Books



I'm almost there. I know I need a filter with in a filter but I cant get that syntax right.

Here is what I have:

\define MyFilter()
[location[$(MyTag)$]sort[title]]
\end


<$set name="MyTag" value={{!!title}}>
<$list filter=<<MyFilter>>>
<div class="tc-menu-list-item">
<$transclude field="subtopic"/>
</div>
<div class="tc-menu-list-subitem">
<$link to={{!!title}}><$view field="title"/
></$link>
<div class="tc-menu-list-subitem">
<$transclude field="blurb"/>
<div class="tc-menu-list-subitem">
<$transclude field="location-help"/>
</div></div></div></$list></$set>


And that gives me more like:

Restaurant
   
Joes Bar
Restaurant
   
Mikes Burgers
Shops
   
Toy n More
Shops
   
Wizard of Books



TonyM

unread,
Jun 24, 2018, 2:43:48 AM6/24/18
to TiddlyWiki
Scott,

To help us understand please show how location relates to your test data. Are you suggesting all in your above data are in the same location.

Because if you do there would be a filter to select the current location then two lists one after the other to show all restaurants and all shops in the current location.

Or perhaps this would be a list of locations with two list restarraunts and shops one after inside the location list.

Here I see only one <$list </$list

Regards
Tony

Scott Kingery

unread,
Jun 24, 2018, 11:52:03 AM6/24/18
to TiddlyWiki
Tony,
There is one list because I cant figure out the syntax for the one that should be inside that.

Let me see if I can explain more...

I have a tiddler called, let say, West Mall. That would be the name of a location.
In the location field on other tiddlers I type West Mall or other names of locations.
Also on other tiddlers I have a filed called subtopic and I type Restaurant or Shop depending on which it is

Now when I open the West Mall tiddler I expect to see all the things with "West Mall" in their location field. That part works in the example. I have a filter and I set the variable with the title of the current tiddler.

\define MyFilter()
[location[$(MyTag)$]sort[title]]
\end


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


I need help trying to group those together by subtopic like in my example.

Hope that helps explain further.

Scott

Mark S.

unread,
Jun 24, 2018, 12:03:44 PM6/24/18
to TiddlyWiki
This is a start. You'll need to weave back in the classes you want. I've changed some filter names.

\define locationfilter()
[blurb[$(blurb)$]location[$(location)$]sort[title]]
\end
\define blurbfilter()
[location[$(location)$]each[blurb]get[blurb]sort[]]
\end


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

<$list filter=<<blurbfilter>> variable="blurb">

<div class="tc-menu-list-item">
<<blurb>>
</div>

<div class="tc-menu-list-subitem">
<$list filter=<<locationfilter>>>

<$transclude field="subtopic"/
>


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

<$transclude field="location-help"/>
</$list>
</
div>

</$list>
</
$set>

General advice -- give fields, filters and other objects meaningful names. This will make things a lot easier as your application gets bigger. In this case I've changed the variable passed from "MyTag" to "location" and given the filters corresponding names. If it was me, I would also change "blurb" to "vendortype" or something that designates what it does.

HTH!

-- Mark

Scott Kingery

unread,
Jun 24, 2018, 3:55:25 PM6/24/18
to tiddl...@googlegroups.com
Thanks Mark I'll see what I can do with this.

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/gEWSkUL-l1M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/19a58ff3-ee44-4a48-8ee3-3db7c7c70f32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

TonyM

unread,
Jun 24, 2018, 9:11:12 PM6/24/18
to TiddlyWiki
Scott,

You can see in marks example that lists within lists are quite simple. indentations are helpful to make it obviouse

Example 3 levels of nesting
<$list
   <$list
      <$list

      </$list>
   </$list>
</$list>

In this we see one list wrapping two lists, in this case one "inner list" list may respond to "has a field or tag value" and the other "NOT has a field or tag value"
<$list
   <$list filter="[is[current]has[fieldname]]"

   </$list>
   <$list filter="[is[current]!has[fieldname]]"

   </$list>
</$list>

So you can see there are possibly infinite variations of nesting lists. All you need to do is keep track of the open and close of each list.

Of course the content of any lists filter can be very sophisticated so the selective logic is often contained in the filter. 

A couple of other key features of using lists include

  • By default the filter will generate a list of (tiddler) titles, and the content inside the list widget will step through each tiddler in that set, basically changing the "current tiddler value for each item.
  • However if on a list widget you specify <$list filter="filter" "variable="myvar"> inside the list widget the current tiddler title changes in <<myvar>>, and the current tiddler remains the same.
  • You can write list filter that have no result, in which case you can use EmptyMessage to return a value in this no result case.
Enjoy
Tony

Scott Kingery

unread,
Jun 27, 2018, 2:55:29 PM6/27/18
to TiddlyWiki
Thanks for the help, everyone. I posted a demo solution for future Googler's here:

Cleaned up some of my code and changed the names of my fields to make more sense.
Reply all
Reply to author
Forward
0 new messages