Difference between revisions of "Template:LinkCatIfExists"

From blackwiki
Jump to navigation Jump to search
imported>BrownHairedGirl
(fix])
imported>BrownHairedGirl
(prettify)
Line 1: Line 1:
<includeonly>{{#ifexist: Category:{{{1|}}} | [[:Category:{{{1|}}}{{!}}{{#if: {{{2|}}}|{{{2|}}}|{{{1|}}}}}|{{#if: {{{2|}}}|{{{2|}}}|{{{1|}}}}}]]}}</includeonly><noinclude>{{Documentation}}</noinclude>
+
<includeonly>{{#ifexist: Category:{{{1|}}} |<!--
 +
# The category does exist
 +
# So create a link
 +
--> [[:Category:{{{1|}}}{{!}}{{#if: {{{2|}}}|{{{2|}}}|{{{1|}}}}}]]<!--
 +
-->|<¬-
 +
# The category does NOT exist
 +
# so just output plaintext
 +
-->{{#if: {{{2|}}}|{{{2|}}}|{{{1|}}}}}]]}}</includeonly><noinclude>{{Documentation}}</noinclude>

Revision as of 08:47, 11 January 2017

Template documentation[view] [edit] [history] [purge]

This is a simple helper template, to be used in other templates. It displays a link to a category if that category exists; otherwise it just displays plaintext.

Optional display text may be added as a second parameter.

Usage

{{LinkCatIfExists|CategoryName|OptionalDisplayText}}

Simple usage
{{LinkCatIfExists|CategoryName}}
Examples:
# The category does NOT exist
# so just output plaintext

-->A non-existent category]]

# The category does NOT exist
# so just output plaintext

-->United States]]

With optional display text
{{LinkCatIfExists|CategoryName|DisplayText}}
Examples:
# The category does NOT exist
# so just output plaintext

-->Foo]]

# The category does NOT exist
# so just output plaintext

-->USA]]

See also