Template:Da smw/doc: Difference between revisions
No edit summary Tag: sourceedit |
No edit summary Tag: sourceedit |
||
Line 1: | Line 1: | ||
{{tlx|da smw}} is a specialised version of {{tl|da}} which makes it possible to strip the [[dab term]] from [[T:SMW|SMW]] | {{tlx|da smw}} is a specialised version of {{tl|da}} which makes it possible to strip the [[dab term]] from [[T:SMW|SMW]]-rich variables in infoboxes or other templates whose goal is to both '''collect and display''' data within the same template -- for example, {{tlx|Infobox Person}}. In such situations, the normal procedure of using {{tl|da}} fails spectacularly, because SMW itself is creating an unusual kind of link. The standard linked output looks like this: | ||
<pre>[[The Eleventh Hour (TV story)|The Eleventh Hour (TV story)]]</pre> | <pre>[[The Eleventh Hour (TV story)|The Eleventh Hour (TV story)]]</pre> | ||
For whatever reason, the SMW coders create links in this very redundant way, which means the only solution is to get rid of the ''second'' [[dab term]] only. | For whatever reason, the SMW coders create links in this very redundant way, which means the only solution is to get rid of the ''second'' [[dab term]] only. | ||
Line 8: | Line 8: | ||
This is a very different principle, however, to the one on which {{tl|da}} works. ''That'' template uses a #switch parser function to figure out what ''kind'' of page it's on -- (TV story), (comic story), etc. -- and then truncates ''that specific'' [[dab term]]. | This is a very different principle, however, to the one on which {{tl|da}} works. ''That'' template uses a #switch parser function to figure out what ''kind'' of page it's on -- (TV story), (comic story), etc. -- and then truncates ''that specific'' [[dab term]]. | ||
''This'' template doesn't use a #switch at all. Instead it uses a single calculation to figure out the position of the parentheses, and then it eliminates everything from the space before the opening parentheses to the closing parentheses. | ''This'' template doesn't use a #switch at all. Instead, it uses a single calculation to figure out the position of the parentheses, and then it eliminates everything from the space before the opening parentheses to the closing parentheses. | ||
<noinclude>[[category:template documentation|{{PAGENAME}}]]</noinclude> | <noinclude>[[category:template documentation|{{PAGENAME}}]]</noinclude> |
Revision as of 15:01, 8 May 2017
{{da smw}} is a specialised version of {{da}} which makes it possible to strip the dab term from SMW-rich variables in infoboxes or other templates whose goal is to both collect and display data within the same template -- for example, {{Infobox Person}}. In such situations, the normal procedure of using {{da}} fails spectacularly, because SMW itself is creating an unusual kind of link. The standard linked output looks like this:
[[The Eleventh Hour (TV story)|The Eleventh Hour (TV story)]]
For whatever reason, the SMW coders create links in this very redundant way, which means the only solution is to get rid of the second dab term only.
The only recourse is the use of the #sub parser function, with which you can take off a negative number of letters at the end of the string, resulting in
[[The Eleventh Hour (TV story)|The Eleventh Hour
Add a closing pair of brackets — ]] — and your golden!
This is a very different principle, however, to the one on which {{da}} works. That template uses a #switch parser function to figure out what kind of page it's on -- (TV story), (comic story), etc. -- and then truncates that specific dab term.
This template doesn't use a #switch at all. Instead, it uses a single calculation to figure out the position of the parentheses, and then it eliminates everything from the space before the opening parentheses to the closing parentheses.