[TW5] <$link to= transclusion of non-standard field doesn't work?

586 views
Skip to first unread message

Mat

unread,
May 21, 2015, 8:22:25 AM5/21/15
to tiddl...@googlegroups.com
I'm making a small "bookmarks presenter" (that's a fancy word for a table with urls).

The following works except to get the word URL to be a link to the value in the tiddlers url field. What I find surprising is that the identical format works for the standard fields, e.g text.

I'd appreciate any guidance on why it doesn't work and how.


\define geturl()
<$transclude tiddler=<<tidname>> field="url"/>
\end

\define gettext()
<$transclude tiddler=<<tidname>> field="text"/>
\end


\define bookmarkstable()
<table>
<$list filter="[tag[Foo]]" variable="tidname">
   <tr>
      <td><$link to=<<geturl>>>URL</$link></td>
      <td><$link to=<<tidname>>><<tidname>></$link></td>
      <td><<gettext>></td>
   </tr>
</$list>
</table>
\end


<:-)

Eric Shulman

unread,
May 21, 2015, 10:52:51 AM5/21/15
to tiddl...@googlegroups.com
On Thursday, May 21, 2015 at 5:22:25 AM UTC-7, Mat wrote:
\define geturl()
<$transclude tiddler=<<tidname>> field="url"/>
\end

\define gettext()
<$transclude tiddler=<<tidname>> field="text"/>
\end


\define bookmarkstable()
<table>
<$list filter="[tag[Foo]]" variable="tidname">
   <tr>
      <td><$link to=<<geturl>>>URL</$link></td>
      <td><$link to=<<tidname>>><<tidname>></$link></td>
      <td><<gettext>></td>
   </tr>
</$list>
</table>
\end

There are a few issues here:
1) The very first line of http://tiddlywiki.com/#LinkWidget says:
The link widget generates links to tiddlers. (Use the HTML <a> element to generate external links). 
Thus, you should not be using the <$link> widget to create an external link.

2) There's no need to use variable="tidname" in the <$list> widget, as it just complicates things.  The default for the <$list> widget is to set "currentTiddler", which has the advantage of also being used as the current "context" for simple {{...}} transclusion, without using the <$transclude> widget.

3) The reason the <<gettext>> macro works but <<geturl>> doesn't is because the <<gettext>> result is being rendered as content, which wikifies the <$transclude> widget that was returned.  In contrast, you are trying to use the result of <<geturl>> as a *param* for the <$link> widget, which does not get wikified and thus remains literally "<$transclude .../>"

Thus, to get things to work as you want:
1) eliminate the macros (not needed)
2) eliminate the use of variable="tidname"
3) use simple transclusion of fields to insert their values

The following works as you want, without needing extra macros

\define bookmarkstable()
<table>
<$list filter="[tag[Foo]]">

   
<tr>
     
<td><a href={{!!url}}>URL</a></td>
     
<td><$link>{{!!title}}</$link></td>
     
<td>{{!!text}}</td>
   
</tr>
</
$list>
</table>
\end
Note: you don't need *any* params for the <$link> widget, since it's default is to use the current tiddler as the target.

enjoy,
-e
Eric Shulman
ELS Design Studios
TiddlyTools - "Small Tools for Big Ideas!"
InsideTiddlyWiki: The Missing Manuals

YOUR DONATIONS ARE VERY IMPORTANT!
HELP ME TO HELP YOU - MAKE A CONTRIBUTION TO MY "TIP JAR"...

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:

Mat

unread,
May 21, 2015, 4:01:55 PM5/21/15
to tiddl...@googlegroups.com
This was not only helpful but also very instructive. Thank you Eric, very much appreciated! Great writeup!

<:-)
Reply all
Reply to author
Forward
0 new messages