[TW5] Show-fields

105 views
Skip to first unread message

Andrew

unread,
Sep 28, 2015, 6:15:58 PM9/28/15
to TiddlyWikiDev
This template causes tiddlers to display the field(s) and value(s) and suppressing the display of system fields if the tiddler has the show-fields field. It has some problems like the show-field has to have something in the value to work and I can't seem to pass more than one field name to the filter. It is tagged $:/tags/ViewTemplate and uses a list filter that I don't understand. I got it mostly working but I want to be able to add or remove displayed fields by passing the field value of my show-field. Any suggestions? Here is my work in progress.

Jeremy Ruston

unread,
Sep 28, 2015, 6:37:45 PM9/28/15
to TiddlyWikiDev
Hi Andrew

Here's a reworked version of your code:

\define body()
<$list filter="[is[current]fields[]sort[]] -draft.of -draft.title -show-field -text -title -modified $(showfield)$" variable="listItem">
<tr class="tc-view-field">
<td class="tc-view-field-name">''<<listItem>>'':</td>
<td class="tc-view-field-value"><$transclude field=<<listItem>>/></td>
</tr>
</$list>
\end

<$list filter="[all[current]has[show-field]]">
<table class="tc-view-field-table">
<tbody>
<$set name="showfield" value={{!!show-field}}>
<<body>>
</$set>
</tbody>
</table>
</$list>

The major changes were:

* Moving the body of the table into a macro so that the $()$ syntax works - textual substitutions only occur when macros are parsed
* Using the "has" filter operator to detect presence of a field
* Removing the double quotes around the "value" attribute of the set widget; they cause their content to be treated as a literal string, so that the {{}} syntax isn't parsed as a transclusion
* Using line-breaks to make the code a bit easier to read

Best wishes

Jeremy.


On Mon, Sep 28, 2015 at 11:15 PM, Andrew <andrew.j....@gmail.com> wrote:
This template causes tiddlers to display the field(s) and value(s) and suppressing the display of system fields if the tiddler has the show-fields field. It has some problems like the show-field has to have something in the value to work and I can't seem to pass more than one field name to the filter. It is tagged $:/tags/ViewTemplate and uses a list filter that I don't understand. I got it mostly working but I want to be able to add or remove displayed fields by passing the field value of my show-field. Any suggestions? Here is my work in progress.

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/7fea2836-3b87-4067-a39b-013a507fdb0c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jeremy Ruston
mailto:jeremy...@gmail.com

Andrew

unread,
Sep 28, 2015, 7:07:01 PM9/28/15
to TiddlyWikiDev, jeremy...@gmail.com
Thank you Jeremy. Your accuracy and precision were amazing. It is so well formed and works so well that I am realizing I need to spend some more time studying your work. And I am floored by how quickly you responded. Thank you.
Reply all
Reply to author
Forward
0 new messages