On Tuesday, August 11, 2015 at 9:40:55 PM UTC+2, Łukasz Hirt wrote:
>
> Hello guys,
>
> First of all, this is my first post here. I think TW is a great piece of 
> tool, but since I am still beginner I would liek to ask you a question:
>

Hi Lukasz, 
Welcome to the club :)
 

>
> I would like to use tiddler's caption as a description of a link. I tried 
> two solutions, one works as expected, another one does not work. 
> Iw ould like to know why the other one does not work.
>
>
> SOLUTION 1 - this works as expected > creates link to MY_TIDDLER but 
> displays the caption of that tiddler
>
> <$link to="MY_TIDDLER"> {{MY_TIDDLER!!caption}} </$link>
>

{{}} is the notation for a transclusion. see: 
http://tiddlywiki.com/#Transclusion and   
http://tiddlywiki.com/#Transclusion%20in%20WikiText
This is the convenience wikitext for the $transclude widget. ...
 

> SOLUTION 2 - this one does not work, WHY ? Instead the caption of 
> MY_TIDDLER it displays {{MY_TIDDLER!!caption}}
>
> [[{{MY_TIDDLER!!caption}}|MY_TIDDLER]]
>
 
see: http://tiddlywiki.com/#Linking%20in%20WikiText ... the above notation 
is a "pretty link". As you found out, it treats the first part in the 
brackets as the "pretty link" text. The transclusion {{}} is not evaluated. 
Only the text is used. So the [[]] notation is "just" a convenience 
function for the link widget. It makes it faster and easier to write but 
for some edge cases it is also limited. 

As you found out. For your behaviour you need the link widget, which  gives 
you maximum flexibility. 

To make your desired function easier to read and write, you can cover it 
into a macro. eg: 

\define myLink(tiddler tooltip:"")
  <$link to="""$tiddler$""" tooltip="""$tiddler$$tooltip$""">
    <$transclude tiddler ="""$tiddler$""" field="caption">
      <$view tiddler ="""$tiddler$""" field="title"/>
    </$transclude>
  </$link>
\end

The above function is a bit more generic. It uses the tiddler title, if 
there is no caption field. 


You can use it with: <<myLink noCaption>>   or  <<myLink "tiddler has a 
caption field">>

lets say the tiddler named noCaption has no caption field. so the title is 
used
lets say the "tiddler has a caption field" has one so the caption is used. 
(sorry for the stupid names)

have fun!
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+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/ec547096-64e9-4df2-92a5-7cb1647646b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to