I want to make WikiText links display the caption if the linked tiddler has a caption.
For example, [[company/apple]] was founded by Steve Jobs
. should be automatically rendered as Apple was founded by Steve Jobs
when the caption of the tiddler company/apple
was Apple
. Although I know that could be done by [[Apple|company/apple]]
, I feel it redundant.
Where should I tweak to make it possible?
If it can be done, my guess for tweaking: $:/core/modules/parsers/wikiparser/rules/prettylink.js
Yuck.
Instinctively, I am “nope, not for me.” I’d much prefer a transclusion template:
{{ company/apple || tLnk }}
tLnk being a transclusion template tiddler.
You can use my uni-link plugin. There are several modes. I personally would suggest to use the aliases feature. So your link would look like this:
The link would be: [[Apple|?]]. The only thing needed is that your tiddler: company/apple
needs an aliases field that contains the value: Apple. …
The advantage is, that you can rename your company/apple tiddler without breaking the link.
You can show every other field eg: [[Apple|?s]]
. where “s” stands for the subtitle
field. … So if you subtitle
contains: Apple was founded by Steve Jobs
the link would be all you would need to write.
[[aPpLe|?myField]] would also find the tiddler with the alias: Apple and show the content of myField
. The alias in the link is not case-sensitive. Which is an advantage for some aliases if you need to write them in the middle of a sentence or at the beginning with a capital letter …
have fun!
Thank you, Mario Pietsch. Definitely, your plugin is just (or better than) what I required.
By setting the value of $:/config/wikilabs/uni-link/field to caption, [[tiddler]] will display the caption of the tiddler. Is that correct?
My aliases could conflict with each other so I use this simple way rather than the alias approach. I can deal with renaming problem by a relink plugin.
Yes. This setting is global. Some examples can be seen at: uni-link — extended link functions
If there is no caption field, it uses the tiddler title, to be sure, that every link shows some text
Whilst supporting the ideas in this thread to answer the Topics key question;
Display the caption of the links instead of its title by default
We can answer this by creating a tiddler eg caption-link containing
<$link to=<<currentTiddler>> ><$text text={{{ [all[current]get[caption]else{!!title}] }}}/></$link>
- Then use
{{||caption-link}}
in current tiddler, or in a list where the currentTiddler variable changes. - Or use
{{tiddlername||caption-link}}
for a specific tiddler (uses caption before title)
I was preparing to give an even more involved answer. Rather than calling it caption-link I am building a tiddler “linker”. Using this {{||linker}}
when ever listing tiddlers links will not only use caption rather than title but also allows other features to be added to the linker tiddler as I come up with them.
I don’t know about you, but this has “caption linker” written all over it, begging for the short moniker:
{{ || clinker }}
or {{ || clink }}
(not “cee link”, but more like “clinking wine glasses”.
Just because cutesy always makes me smile…
The problem with that solution is, that it doesn’t create backlinks. Uni-link does create backlinks for links and aliases
Good, point and I would urge uni-link for that if needed, my example is perhaps the simplest case.
I am actually building a linker tool, in part triggered by this Topic, to make links from any list much more functional. I must keep in mind the possibility of making backlinks work, although personally I am not so worried in standard lists.
Backlinks need JavasScript support. It’s needed to “walk” the tiddler parsetree and create an index if it should be performant.
I was talking about designing my solution so it made use of current backlink detection if possible. Not reinventing it.