Discussion:
[tw] Empty list substitution in a view template
Dmitry Skopa
2016-08-01 08:37:20 UTC
Permalink
Hello everyone!

I've found very useful to have a list of all related tiddlers (tagged with
current tiddler) always visible at the bottom of a current tiddler.

I have a $:/tags/ViewTemplate tiddler with field list-after set to
$:/core/ui/ViewTemplate/body and this contents:

<$list filter="[all[current]]">
<h1>Related:</h1>
<ul>
<$list filter="[all[current]tagging[]sort[modified]]">
<li>
<$link to={{!!title}}><$view field="title"/></$link>
</li>
</$list>
</ul>
</$list>

This works the way I want except one thing: I would like to remove
"Related:" header when the list is empty. Is it possible?
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/a6d419b9-8275-4cae-88bc-c90de4604450%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
PMario
2016-08-01 13:11:29 UTC
Permalink
Hi,

Not a real solution, but imo a workaround to make the "Related" text more
meaningful. ... The list widget has an "emptyMessage"
http://tiddlywiki.com/#ListWidget parameter. You can use it, to have a text
eg: "-- no related tiddlers --". So users know, what's going on.

-mario
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/d047fbee-a0c7-43ef-bc27-b18dfbb08926%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dmitry Skopa
2016-08-02 04:55:42 UTC
Permalink
emptyMessage is a good thing to mark nothing is found, but I'm still have a
useless header which I want to avoid
Post by PMario
Hi,
Not a real solution, but imo a workaround to make the "Related" text more
meaningful. ... The list widget has an "emptyMessage"
http://tiddlywiki.com/#ListWidget parameter. You can use it, to have a
text eg: "-- no related tiddlers --". So users know, what's going on.
-mario
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/061949b5-1420-405c-8545-4da6ea3f3390%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Eric Shulman
2016-08-01 13:41:00 UTC
Permalink
Post by Dmitry Skopa
<$list filter="[all[current]]">
<h1>Related:</h1>
<ul>
<$list filter="[all[current]tagging[]sort[modified]]">
<li>
<$link to={{!!title}}><$view field="title"/></$link>
</li>
</$list>
</ul>
</$list>
This works the way I want except one thing: I would like to remove
"Related:" header when the list is empty. Is it possible?
Instead of writing just:
<h1>Related:</h1>
you can enclose it in a <$list> widget like this:
<$list filter="[all[current]tagging[]sort[modified]limit[1]]">
<h1>Related:</h1>
</$list>

This <$list> widget uses the same filter syntax as the <$list> widget that
actually produces the link output, but with the added "limit[1]". This
effectively turns the widget into a test that says "if the filter results
are not empty, show the heading". Note: you can optimize this filter a bit
more by leaving out the "sort[modified]" syntax, since it doesn't affect
the test conditions.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/571e6086-273f-452a-8e09-a2bda78a3a7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Dmitry Skopa
2016-08-02 04:57:39 UTC
Permalink
This works pretty well, thank you. But wouldn't it cause tiddlywiki to run
same search routine twice?
Post by Dmitry Skopa
Post by Dmitry Skopa
<$list filter="[all[current]]">
<h1>Related:</h1>
<ul>
<$list filter="[all[current]tagging[]sort[modified]]">
<li>
<$link to={{!!title}}><$view field="title"/></$link>
</li>
</$list>
</ul>
</$list>
This works the way I want except one thing: I would like to remove
"Related:" header when the list is empty. Is it possible?
<h1>Related:</h1>
<$list filter="[all[current]tagging[]sort[modified]limit[1]]">
<h1>Related:</h1>
</$list>
This <$list> widget uses the same filter syntax as the <$list> widget that
actually produces the link output, but with the added "limit[1]". This
effectively turns the widget into a test that says "if the filter results
are not empty, show the heading". Note: you can optimize this filter a bit
more by leaving out the "sort[modified]" syntax, since it doesn't affect
the test conditions.
enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/dc4bc0a9-c127-4789-a391-f9a1ba142987%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Eric Shulman
2016-08-02 06:23:09 UTC
Permalink
Post by Dmitry Skopa
This works pretty well, thank you. But wouldn't it cause tiddlywiki to run
same search routine twice?
Yes, but this particular search is pretty efficient... "all[current]" is a
simple reference to the current tiddler context (which is automatically
tracked by the core), "sort[modified]" can be omitted (since you are only
testing for non-empty), and "limit[1]" merely truncates the filter result
to one item. Only the "tagging[]" filter has any real lookup processing,
and even that is relatively efficient since you are only looking for one
specific tag (the current tiddler), so performance is linear, based on the
total number of tiddlers.

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios
InsideTiddlyWiki: The Missing Manuals
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+***@googlegroups.com.
To post to this group, send email to ***@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/9548554b-4e19-445b-8d3d-b460264f8be4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...