[TW5]Wikipedia style "See also:" filter ?

157 views
Skip to first unread message

Mat

unread,
Apr 27, 2015, 6:05:52 AM4/27/15
to tiddl...@googlegroups.com
I'm writing a bunch of articles and wish to include "See also:" viewtemplate sections at the end, like on Wikpedia.

For this a filter is needed but I can't figure out how to compose it, as per:

I hope to have a whitelist for specific tags in a separate tiddler, SeeAlsoList.

I now wish to go through the tags of the current articles,
and for each tag that is whitelisted
look for all other articles that also has this tag.
If (and only if) such exist, a "See also:" section is created showing the title of those other articles.

There can thus be many "See also:" sections in one article.

My hope is to be able to display the articles inside the core Table of Contents macro - and still see the "See also:" sections.

Thank you!

<:-)


Jed Carty

unread,
Apr 27, 2015, 1:57:48 PM4/27/15
to tiddl...@googlegroups.com
I am not certain what your last line means, but the first part isn't too hard:

The easiest way to build it I can think of at the moment would be to use a list field to define the whitelisted tags for each tiddler, so you would have a field, in the example below called see_also_tags, and in that field you would list all of the tags you want whitelisted for the tiddler. You need to put [[ and ]] around any tags that have spaces in the names, and you need spaces between tags like this ATag [[Some multi word tag]] [[some other tag]]. (I just put that last bit in because I always forget that part.)
Create a custom view template with this (that is make a tiddler with whatever name you want, give it the tag $:/tags/ViewTemplate and put this in the text field):

<$list filter='[list[!!see_also_tags]]' variable=CurrentTag>
<$list filter='[tag<CurrentTag>limit[1]]'>
See Also:
<$list filter='[tag<CurrentTag>]'>

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

You can change the name of the field used to whatever you want. You may want to add tag[Article] or something else to the inner filters, but this general form should get you what you want.

Mat

unread,
Apr 27, 2015, 3:51:05 PM4/27/15
to tiddl...@googlegroups.com
@Jed - I really appreciate your answer!

It works great! Except that last cryptic bit about the Table of Contents macro. I put up a tiddlyspot, seealso, to show exactly what I mean. I added some minor tweaks, and decided to put the whitelist in a separate tiddler.

I'm guessing the difficulty with the ToC is that it causes the CurrentTag to refer to it, the ToC, instead - or?

Again, thank you for your kind reply Jed!

<:-)

Mat

unread,
Apr 27, 2015, 3:52:22 PM4/27/15
to tiddl...@googlegroups.com
Oh, the password is the same as the title, i.e seealso, so that if you want then you can test straight in there.

<:-)

Jed Carty

unread,
Apr 27, 2015, 5:45:59 PM4/27/15
to tiddl...@googlegroups.com
Oh, a tabbed table of contents. For that it can actually be simpler, just put 'template=ViewTemplate' in the macrocall for the table of contents. So your toc tiddler would be:

<$macrocall
    $name="toc-tabbed-internal-nav"
    tag="ToC"
    selectedTiddler="$:/temp"
    unselectedText="<p>Select a topic in the table of contents. Click the arrow to expand a topic.</p>"
    missingText="<p>Missing tiddler.</p>"
    template='ViewTemplate'
/>

That should work.

And I had misunderstood what you wanted with the tags, but it looks like you have that working fine.

Mat

unread,
Apr 27, 2015, 7:12:03 PM4/27/15
to tiddl...@googlegroups.com
Thak you Jed! That template parameter was interesting to learn about. Thing are getting really close (and while I really appreciate your help, there is of course no "commitment" just because you've been so generous so far).

The idea is simply to present the tiddlers to the reader so that they can read the contents and see the "See also:" section, kind of like on e.g Wikipedia. But some of the tiddlers will be presented separately (like normal tiddlers) and some will be in ToC. Either way should be able to show a "See also"

The reason for using a ToC for some of them is that it is in the case of various listings where a separate tiddler is less interesting in itself (...hm, I'm getting tempted to show you what I'm working on... should I? It's a community thing but it's still not mature for release so it might be confusing...). Anyway, so the plain article variant has already been solved with your help. But for the ToC display I'm wondering if it is possible to get all the usual view stuff seen?

I added some further experimenting on the tiddlyspot site. Using template="$:/core/ui/ViewTemplate" results in the whole tiddler unsuccessfully crammed into the ToC. And trying to display the name+tags+text by adding <<currentTiddler!!xxx>> into the template ViewTemplateB not only does now fetch the tags or the text but it also affects the ToC itself... Maybe I can't use <<currentTiddler>> macro there...

Ideas anyone?

Thank you!

<:-)

Jed Carty

unread,
Apr 27, 2015, 7:38:07 PM4/27/15
to tiddl...@googlegroups.com
Looking at what you have there, you can't use currentTiddler like <<currentTiddler!!tags>>, in that case you have a few options:

{{!!tags}} - this is exactly what it looks like you were trying to do, this shows the contents of the tags field
<$transclude field='tags'/> or <$transclude tiddler=<<currentTiddler>> field='tags'/>
<$view field='tags'/> or <$view tiddler=<<currentTiddler>> field='tags'/>

for text it is the same thing, just replace 'tags' with 'text' in the above examples.

The first option is just an easier version of the second option with a few restrictions. Using $view gives the result as plain text while the other two will wikify what they display.

You can selectively apply the view template by giving tiddlers you don't want it to work on a tag or field. I am going to say a tag 'NoView' then wrap the view template in this:

<$list filter='[is[current]!tag[NoView]]'>
(the rest of the view template text goes here)
</$list>

Mat

unread,
Apr 28, 2015, 5:21:45 AM4/28/15
to tiddl...@googlegroups.com
Jed - it works excellent now.

I just realized someone else may appreciate it so in the SeeAlso: tiddlyspot  I threw in an introductory presentation.

Thank you for your help!

<:-)

Sylvain Naudin

unread,
Apr 28, 2015, 5:56:44 PM4/28/15
to tiddl...@googlegroups.com
Excellent ! Good idea Mat and good job Jed :)

I just play with your online example, and wondering how we could limit result in case of many tiddler with the same tag ?

Could we imagine set max tiddler and random function ?

Reply all
Reply to author
Forward
0 new messages