This is the first post in an irregular series of nifty tricks that saved my day when using MediaWiki and which maybe are useful for you, too…
Sometimes you may want to color a wikilink (for example in order to indicate that two wikilinks are pointing to fundamental different kinds content) with something different than standard blue for existant pages (Monobook).
A minimal wiki code example for turning a wiki link green:
[[ARTICLE|<span style="color:green;">ARTICLE</span>]]
The trick is to do the coloring inside the alternative text and not outside the link brackets (thanks to Shardsofmetal for the hint). However there is a problem: In case ARTICLE does not exist, the link would be still green instead of red for indicating missing content. Using the „ifexist“ function of the parser functions extension this can be solved (splitted one-liner):
[[ARTICLE|{{#ifexist: ARTICLE
|<span style="color:green;">ARTICLE</span>
|ARTICLE}}]]
Now the link turns green in case ARTICLE exists and stays with the default red in case not.
Of course this is rather long winded and you probably want to shorten this with a template if you’re using this more than once. So the template code would be like that:
[[{{{1}}}|{{#ifexist: {{{1}}}
|<span style="color:green;">{{{1}}}</span>
|{{{1}}}}}]]
The wiki code using such a link does look with the template much shorter now:
{{TEMPLATENAME|ARTICLE}}
But now there is a new problem when using a template. You sometimes want to link with a different expression like COOL PAGE to ARTICLE. The solution for the template code is using an optional second variable:
[[{{{1}}}|{{#ifexist: {{{1}}}
|<span style="color:green;">{{{2|{{{1}}}}}}</span>
|{{{2|{{{1}}}}}}}}]]
Now you can call it both ways:
{{TEMPLATENAME|ARTICLE}}
{{TEMPLATENAME|ARTICLE|ALTERNATIVE LINK TEXT}}
Dislcaimer: Make spare use of it. To much stuff at once cocks up the „wow nice effect“. 😉
9. Januar 2008 um 4:54 pm |
This is great. I’m a n00b trying to make wiki’s, reading books, scouring sites. It so helpful to find plain English, useful tips. Made my day!
23. Oktober 2008 um 4:06 pm |
Thanks, this helped me a lot for my quick fix where I didn’t have to change the pre-defined color settings that would have affected the whole wiki.
25. Februar 2011 um 1:47 am |
Thanks a lot for sharing, nice trick, saved me lot of time 🙂
Vielen Danke !
24. Juni 2011 um 8:34 pm |
http://en.wikipedia.org/wiki/Wikipedia:Link_color
^^^^ better way.
2. Oktober 2012 um 4:55 pm |
It is appropriate time to make a few plans for the longer term and it is time to be happy.
I’ve read this post and if I may I wish to recommend you some interesting issues or advice. Perhaps you can write next articles referring to this article. I wish to read more things approximately it!
5. Mai 2013 um 3:22 am |
Fascinating blog! Is your theme custom made or did you download
it from somewhere? A design like yours with a few simple adjustements would really make my blog stand out.
Please let me know where you got your theme.
With thanks
6. Mai 2013 um 4:42 pm |
Hey there! This is kind of off topic but I need some guidance from an established blog.
Is it difficult to set up your own blog? I’m not very techincal but I can figure things out pretty quick. I’m thinking about setting
up my own but I’m not sure where to begin. Do you have any points or suggestions? Many thanks
4. Juli 2014 um 8:11 pm |
These are actually impressive ideas in about blogging. You have touched some
fastidious factors here. Any way keep up wrinting.