Transcluding the title of the current tiddler

130 views
Skip to first unread message

jonath...@wolke7.net

unread,
Jul 26, 2016, 7:57:44 AM7/26/16
to tiddl...@googlegroups.com

 

Hi there,

 

i want to transclude the title of the current tiddler within a macro.

 

Firstly, here ist he macro:

 

\define myMacro()

---

look here for more informations: [[ {{!title}} (Info) ]]

---

 

\end

 

 

Secondly, here ist the macro call:

 

<<<myMacro>>>

 

Thirdly, this should be seen:

 

A link to a tiddler with a title which consists of a) the current tiddler   and b) the string  „ (Info“)

 

 

Background: I’m developing a set of flash cards and on the top of each page there should be a link to an „info-page“ for the current tiddler.

 

Thanks in advance

 

Jonathan

 

Mark S.

unread,
Jul 26, 2016, 10:33:27 AM7/26/16
to TiddlyWiki, jonath...@wolke7.net
Try:

\define myMacro()
---
<$set name=ttl value={{!!title}}>
<<myMacro2>>
</$set>

---
\end
\define myMacro2()
look here
for more informations: [[ $(ttl)$ (Info) ]]
\end


<<myMacro>>

jonath...@wolke7.net

unread,
Jul 26, 2016, 2:32:41 PM7/26/16
to tiddl...@googlegroups.com

Thanks, your solution is working – great!

 

One more question:

How would I do it the other way round:

 

Linking from „myTiddler (info)“ to „myTiddler“  ?

 

I would have to shorten the title oft the current tiddler, i.e. cut off the last 6 or 7 characters.

 

How would I do this?

Mark S.

unread,
Jul 26, 2016, 5:32:33 PM7/26/16
to TiddlyWiki, jonath...@wolke7.net
This seems to work:

\define mac2(ttl)
<$list filter=" [[$ttl$]]  +[removesuffix[ (Info)]]" />
\end
\define mac1()
---
The following contains details relating to <$macrocall $name=mac2 ttl={{!!title}}/>

---
\end

<<mac1>>


However, it doesn't work in preview, which threw me off for awhile. Perhaps one of the gurus here can explain why it works in implementation but not in preview. I could also make a version that worked in preview but not in the real tiddler. The difference between the two versions was the square brackets around the variable [[$ttl$]] in the macro.

Good luck!
Mark

c pa

unread,
Jul 26, 2016, 5:40:55 PM7/26/16
to TiddlyWiki, jonath...@wolke7.net
It doesn't work in preview because during editing the title is "Draft of" + title

Draft of + title isn't contained in any foreign fields

Mark S.

unread,
Jul 26, 2016, 5:57:54 PM7/26/16
to TiddlyWiki, jonath...@wolke7.net
But, why should that make a difference to removing the suffix ? When I say that it doesn't work, I mean that it shows nothing. I could understand if I was removing a prefix, since the prefix would be displaced by "Draft of".

Thanks!
Mark

RichardWilliamSmith

unread,
Jul 26, 2016, 9:24:28 PM7/26/16
to TiddlyWiki, jonath...@wolke7.net
Yes, it removes the suffix, leaving you with the title, minus " (info)" - only in edit mode, the title of the tiddler you're editing has "draft of" appended to the front, so it doesn't point to your original tiddler. I think, possibly, drafts are anyway excluded from filter results by default (?)

If you want to, you can edit the text of tiddlers without putting them into draft mode, by creating your own editor - I think Mat made something called the "side editor" that does that (?).

Regards,
Richard

Mark S.

unread,
Jul 27, 2016, 12:15:51 AM7/27/16
to TiddlyWiki, jonath...@wolke7.net
You have to try the code to see what I mean. When I say that it doesn't produce a link, I mean that it doesn't produce any text (linked or otherwise). That's why it's a bit mysterious. I would have expected it to produce a nowhere-link like "Draft of <title>"

Mark

Matabele

unread,
Jul 27, 2016, 12:41:23 AM7/27/16
to TiddlyWiki, jonath...@wolke7.net
Hi

No need for a double macro -- this seems to work:

\define myTitle(title) $title$ info""

<<myTitle {{!!title}}>>

-- not too sure what your desired string should be
-- the macrocall can be used as a variable for setting a parameter elsewhere

regards

RichardWilliamSmith

unread,
Jul 27, 2016, 1:39:15 AM7/27/16
to TiddlyWiki, jonath...@wolke7.net
Yes, but it's listing the tiddlers that match. In view mode, there should (can) only be one match, but in edit mode there are no matches.

jonath...@wolke7.net

unread,
Jul 27, 2016, 4:32:46 AM7/27/16
to tiddl...@googlegroups.com

Hi Matabele,

 

indeed, your approach does work for pure listing, but if you want to link to this very tiddler, it does not work …

 

\define myTitle(title) [[$title$ info]]

<<myTitle {{!!title}}>>

 

leaves you with a link to „{{!!title}} info“.

 

jonath...@wolke7.net

unread,
Jul 27, 2016, 6:28:49 AM7/27/16
to tiddl...@googlegroups.com

Thank you, Mark!

You are the guru here…

Reply all
Reply to author
Forward
0 new messages