As a secondary issue, the results of the <$view field="defn" /> line are not being parsed properly as wikitext, yet when I use {{!!defn}} on the tiddler where the field is created, it shows properly as wikitext. What gives?
This is my first attempt at displaying content programmatically within a tiddler. Well, almost my first anyway. I have successfully displayed a tiddler field in the text of the same tiddler itself, using {{!!fieldname}}, but apart from that this is all new territory for me.
As you'll see from the attached screenshot, I'm trying to build a list of definitions of technical terms, using a <$list>..</$list> code block, containing <$view field="fieldname" /> elements. But I'm trying to format the results as a definition list using the semicolon and colon tags. This clearly isn't quite working for me, and I was wondering how to make it work properly. My logic seems sound, and it is displaying the results I expected, but not with the formatting I had hoped for.
I've tried looking at the official TW5 documentation, searching through the forums, and staring blankly for many long hours at @Tobi's example code, as mentioned in another recent discussion thread, but I still can't work it out. I guess I need to be using a <dl>..</dl> code block rather than <$list>..</$list>, but I cannot work out how to change the parameters in Tobi's example to make them do what I am trying to do.
<$list filter="[tag[Definitions]]">
; <$view field="title"/>
: <$transclude field="defn"/>
</$list><dl>
<$list filter="[tag[Definitions]]">
<dt><$view field="title"/></dt>
<dd><$transclude field="defn"/></dd>
</$list>
</dl>
Usually, the mode is determined by whether the transclude widget itself has been parsed in block or inline mode. This can be overridden with themodeattribute.
[[GIMP]] is an [[<abbr title="<$transclude tiddler="Open Source" field="defn" mode="inline"/>">open source</abbr>|Open Source]] graphics application.
[[GIMP]] is an [[<abbr title="<$transclude tiddler="Open Source" field="defn" mode="inline"/>">open source</abbr>|Open Source]] graphics application.
[[GIMP]] is an <$link to="Open Source"><abbr title={{Open Source!!defn}}>Open Source</abbr></$link> graphics application\define dlink(target)
<$link to="""$target$"""><abbr title={{$target$!!defn}}>$target$</abbr></$link>
\end[[GIMP]] is an <<dlink "Open Source">> graphics application<$link to="Open Source" tooltip={{Open Source!!dfn}} tag="abbr">open source</$link>
or:
<$set name="tv-wikilink-tooltip" value="{{!!dfn}}">
<$link to="Open Source" tag="abbr">open source</$link>
</$set>
You can remove the tag attribute if it is not necessary to what you want.I guess there must be some way to make this macro accessible globally within my wiki, by moving the macro definition into a new tiddler named something like $:/_Macros/defn-link or something. Is that all I'd need to do to make it globally accessible to other tiddlers within my wiki?
\define dlink(target)
<$tiddler tiddler="$target$">
<$link><abbr title={{!!defn}}>$target$</abbr></$link>
</$tiddler>
\end<<defn-link "tiddler-name">> as per my new macro, right? Extending this further, how would I (optionally) convert the resulting link to lowercase characters? I often use [[open source|Open Source]] notation within my regular links, so that the displayed text is lowercase, but the link to the tiddler itself is passed as mixed-case. The macro I'm now using returns the tiddler name as it is, which I default to naming them all mixed-case. However, in the body text I want them to appear as lowercase. I'd like this to become a toggleable option in the macro, such as...<<defn-link "tiddler-name" case="lower">>Hi Hegart,I guess there must be some way to make this macro accessible globally within my wiki, by moving the macro definition into a new tiddler named something like $:/_Macros/defn-link or something. Is that all I'd need to do to make it globally accessible to other tiddlers within my wiki?I guess that doc tiddler would benefit from the words "global macro".
- tb
Thanks @Eric and @Evolena, it's always great to get multiple answers showing different ways of achieving something, it gives me more opportunity to learn.
Speaking of which, I just wanted to explain myself a bit, and why I'm asking all these strange questions. I'm really struggling to understand the official TW5 documentation. It seems to be written from the perspective of a developer, rather than an end-user. No disrespect to those who have contributed to the current official TW5 documentation, and I'm sure it works fine for many/most end-users who begin using TW5 from a more knowledgeable position than I have.
On that note, I tried both of your solutions, and both worked fine, but I had to change the tiddler variable to defn in Evolena's. Your solution made use of the tooltip attribute of the LinkWidget, which resulted in a single dotted underline under the link, while Eric's solution gave a double underline. Not sure what the difference is.
Eric's was the first macro I've used in a new tiddler in my TW implementation. I copied the macro definition to the very top of the tiddler, and the call to the macro lower down in the body text of the same tiddler. I guess there must be some way to make this macro accessible globally within my wiki, by moving the macro definition into a new tiddler named something like $:/_Macros/defn-link or something. Is that all I'd need to do to make it globally accessible to other tiddlers within my wiki?
I must admit that I'm not fond of the new documentation too, I often open an old TW5.1.7 to retrieve a simplest presentation.
{{Transclusion||$:/core/ui/TagTemplate}}
Gah!
For example, it's a detail but I don't like to have to open a new tiddler to access examples.
I try to reduce the number of orphans and missing tiddlers in my TW wiki as much as I can. I just thought this information might be useful to somebody.
The first issue you're encountering here is that the term/definition syntax is "block mode", so you need a linebreak after your entering list (else the whole content of the list is parsed as inline mode, and the term/definition syntax is not recognized):<$list filter="[tag[Definitions]]">
; <$view field="title"/>
: <$transclude field="defn"/>
</$list>
You can then have another issue: each "; :" syntax for the definition will be its own definition list, and you will have margins after each term/definition couple.
If you want to avoid that, you have to switch to HTML, in order to declare the definition list outside the list widget (and this way you don't need the extra linebreak...):<dl>
<$list filter="[tag[Definitions]]">
<dt><$view field="title"/></dt>
<dd><$transclude field="defn"/></dd>
</$list>
</dl>
<dl>
<$list filter="[tag[Definitions]]">
<dt><$link><$view field="title"/></$link></dt>
<dd><$transclude field="defn"/></dd>
</$list>
</dl>
<strong><a href="link.html" /></strong>;''[[This Tiddler]]''
: Definition
I see there is a template parameter of the <$view> widget which I think would do this, I just don't know how to use it, and there is no example in the official TW docs on ViewWidget.
- Referencing a field of a tiddler is not the same as linking to a tiddler directly, so if the reference is the only link, then the target tiddler will still be an orphan.
EDIT: It's okay, I worked it out myself. I just had to encapsulate the <$view> in a blank <$link> code block, like this..<dl>
<$list filter="[tag[Definitions]]">
<dt><$link><$view field="title"/></$link></dt>
<dd><$transclude field="defn"/></dd>
</$list>
</dl>
The next trick would be re-applying the <strong> text formatting to the <dt> element, as well as it being a link, resulting in something like this (as a raw HTML example)...<strong><a href="link.html" /></strong>
...or in plain wikitext...I see there is a template parameter of the <$view> widget which I think would do this, I just don't know how to use it, and there is no example in the official TW docs on ViewWidget.;''[[This Tiddler]]''
: Definition
EDIT: Nope, neither format nor template of <$view> seem to be able to apply formatting to the link, and I tried inline CSS on the <dt> element, as <dt style="font-weight: bold;"> but that doesn't work either.
Maybe you will have to define a new CSS... er... I don't know the correct term... "line" in a stylesheet tiddler, in order to override the appearance of a link in a dt element. I don't remember how to do that without searching, and I haven't enough time for that just now, sorry.
\define boldlink(target)
<$tiddler tiddler="$target$">
<$link to={{!!title}}>''$target$''</$link>
</$tiddler>
\end<dl>
<$list filter="[tag[Definitions]]">
<dt><<boldlink>></dt>
<dd><$transclude field="defn"/></dd>
</$list>
</dl>
Because orphans and missing tiddlers, as well as backlinks/references, only takes into account the links to explicitely named tiddlers (either with the link widget or the [[...]] shorthand), but doesn't resolve all the textReference (if the title of the tiddler you want to link to is stored in a field) or variable used in, for example, templates.
!! Definitions
<$list filter="[tag[Definitions]sort[title]]">
!!! <$link>''<$view field="title"/>''</$link>
> <small><$transclude field="defn"/></small>
</$list>Why?
Because orphans and missing tiddlers, as well as backlinks/references, only takes into account the links to explicitely named tiddlers (either with the link widget or the [[...]] shorthand), but doesn't resolve all the textReference (if the title of the tiddler you want to link to is stored in a field) or variable used in, for example, templates.
I'll make a post for it on tb5 later...
Hey, what was that @@..@@ code block you demonstrated? Is that easy to implement, or does it require fiddling with stylesheets in the background to achieve that? Is there a list somewhere of the options that can be used in place of the .info ?
@@color:red; some content @@