Difference between revisions of "Template:Bc"
Jump to navigation
Jump to search
imported>Haama (All fixed) |
imported>Haama (Added notes) |
||
Line 1: | Line 1: | ||
<noinclude>Add <nowiki>{{Bc|Back Article|Hyperlink Text}}</nowiki> to the top line of an article to add a breadcrumb back to the previous article in a hierarchy. | <noinclude>Add <nowiki>{{Bc|Back Article|Hyperlink Text|Back Article 2|Hyperlink Text 2|Back Article 3| Hyperlink Text 3|Back Article 4|Hyperlink Text 4}}</nowiki> to the top line of an article to add a breadcrumb back to the previous article in a hierarchy. | ||
* Back Article is the title of the article that is above the current one in the hierarchy. | * Back Article is the title of the article that is above the current one in the hierarchy. | ||
* Hyperlink Text is what the link should read. May be omitted, and the article title (sans Namespace) will be used instead. | * Hyperlink Text is what the link should read. May be omitted, and the article title (sans Namespace) will be used instead. | ||
* If <nowiki>{{Bc}}</nowiki> is used without either parameter, it defaults to the Main Page of the current Namespace. | * If <nowiki>{{Bc}}</nowiki> is used without either parameter, it defaults to the Main Page of the current Namespace. | ||
* Multiple | * Multiple pages can be called. | ||
[[Category: Templates|Bc]] | [[Category: Templates|Bc]] | ||
[[Category: Structural Templates|Bc]] | [[Category: Structural Templates|Bc]] | ||
</noinclude><includeonly><div style="margin: -0.5em 0.5em 0.5em -0.5em;"><small>Back to:<br><ul>< [[:{{NAMESPACE}}:{{{1|Main Page}}}|{{ #if: {{{2|}}}|{{{2}}}|{{{1|Main Page}}} }}]] {{ #if: {{{3|}}}|< [[:{{NAMESPACE}}:{{{3|Main Page}}}|{{ #if: {{{4|}}}|{{{4}}}|{{{3|Main Page}}} }}]] }} {{ #if: {{{5|}}}|< [[:{{NAMESPACE}}:{{{5|Main Page}}}|{{ #if: {{{6|}}}|{{{6}}}|{{{5|Main Page}}} }}]] }} {{ #if: {{{7|}}}|< [[:{{NAMESPACE}}:{{{7|Main Page}}}|{{ #if: {{{8|}}}|{{{8}}}|{{{7|Main Page}}} }}]] }}</ul></small></div></includeonly> | </noinclude><includeonly><div style="margin: -0.5em 0.5em 0.5em -0.5em;"><small>Back to:<br><ul>< [[:{{NAMESPACE}}:{{{1|Main Page}}}|{{ #if: {{{2|}}}|{{{2}}}|{{{1|Main Page}}} }}]] {{ #if: {{{3|}}}|< [[:{{NAMESPACE}}:{{{3|Main Page}}}|{{ #if: {{{4|}}}|{{{4}}}|{{{3|Main Page}}} }}]] }} {{ #if: {{{5|}}}|< [[:{{NAMESPACE}}:{{{5|Main Page}}}|{{ #if: {{{6|}}}|{{{6}}}|{{{5|Main Page}}} }}]] }} {{ #if: {{{7|}}}|< [[:{{NAMESPACE}}:{{{7|Main Page}}}|{{ #if: {{{8|}}}|{{{8}}}|{{{7|Main Page}}} }}]] }}</ul></small></div></includeonly><noinclude>==Code== | ||
<pre><div style="margin: -0.5em 0.5em 0.5em -0.5em;"><small>Back to:<br><ul>< [[:{{NAMESPACE}}:{{{1|Main Page}}}|{{ #if: {{{2|}}}|{{{2}}}|{{{1|Main Page}}} }}]] {{ #if: {{{3|}}}|< [[:{{NAMESPACE}}:{{{3|Main Page}}}|{{ #if: {{{4|}}}|{{{4}}}|{{{3|Main Page}}} }}]] }} {{ #if: {{{5|}}}|< [[:{{NAMESPACE}}:{{{5|Main Page}}}|{{ #if: {{{6|}}}|{{{6}}}|{{{5|Main Page}}} }}]] }} {{ #if: {{{7|}}}|< [[:{{NAMESPACE}}:{{{7|Main Page}}}|{{ #if: {{{8|}}}|{{{8}}}|{{{7|Main Page}}} }}]] }}</ul></small></div></pre> | |||
The code is a bit of a mess, so here's the separate parts: | |||
*<nowiki><div...><small></nowiki> | |||
**Formatting | |||
*<nowiki>Back to:<br></nowiki> | |||
**Creates the top "Back to:" part | |||
*<nowiki><ul></nowiki> | |||
**<nowiki>This tag is used to indent the links (<p> and colon don't work)</nowiki> | |||
*<nowiki>[[:{{NAMESPACE}}:{{{1|Main Page}}}|{{ #if: {{{2|}}}|{{{2}}}|{{{1|Main Page}}} }}]]</nowiki> | |||
**This is the first link and hypertext | |||
**<nowiki>:{{NAMESPACE}}:{{{1|Main Page}}}</nowiki> | |||
***Link to first parameter, or '''Main Page''' if first parameter is undefined | |||
**<nowiki>{{ #if: {{{2|}}}|{{{2}}}|{{{1|Main Page}}} }}</nowiki> | |||
***Hypertext - uses 2nd parameter if defined, 1st if 2nd is undefined or empty and 1st parameter is defined, '''Main Page''' if neither 1st or 2nd parameter is defined | |||
****Note that the test for the '''If''' statement includes a default empty string - this is because an undefined parameter would return true and only empty strings return false (see [http://en.wikipedia.org/wiki/Help:Template#Parameters this page] for the trick) | |||
*" " | |||
**Space for the next carot | |||
*<nowiki>{{ #if: {{{3|}}}|< [[...]]}}</nowiki> | |||
**If there is a third parameter, then render the link and hypertext of the 2nd Back Article | |||
*"< " | |||
**Note that this isn't " < " - the space before the carot doesn't show up (hence the space above) | |||
*<nowiki>[[:{{NAMESPACE}}:{{{3|Main Page}}}|{{ #if: {{{4|}}}|{{{4}}}|{{{3|Main Page}}} }}]]</nowiki> | |||
**The link and hypertext for the 2nd Back Article - breaks down like the first one | |||
**<nowiki>:{{NAMESPACE}}:{{{3|Main Page}}}</nowiki> | |||
***Link - note it uses the 3rd parameter instead of the 1st | |||
**<nowiki>{{ #if: {{{4|}}}|{{{4}}}|{{{3|Main Page}}} }}</nowiki> | |||
***Hypertext - note it uses the 3rd and 4th parameters instead of the 1st and 2nd | |||
*Repeat for the each back articles | |||
*Close up the formatting (<nowiki></ul></small></div></nowiki>) | |||
</noinclude> |
Revision as of 23:45, 14 December 2008
Add {{Bc|Back Article|Hyperlink Text|Back Article 2|Hyperlink Text 2|Back Article 3| Hyperlink Text 3|Back Article 4|Hyperlink Text 4}} to the top line of an article to add a breadcrumb back to the previous article in a hierarchy.
- Back Article is the title of the article that is above the current one in the hierarchy.
- Hyperlink Text is what the link should read. May be omitted, and the article title (sans Namespace) will be used instead.
- If {{Bc}} is used without either parameter, it defaults to the Main Page of the current Namespace.
- Multiple pages can be called.
Code
<div style="margin: -0.5em 0.5em 0.5em -0.5em;"><small>Back to:<br><ul>< [[:{{NAMESPACE}}:{{{1|Main Page}}}|{{ #if: {{{2|}}}|{{{2}}}|{{{1|Main Page}}} }}]] {{ #if: {{{3|}}}|< [[:{{NAMESPACE}}:{{{3|Main Page}}}|{{ #if: {{{4|}}}|{{{4}}}|{{{3|Main Page}}} }}]] }} {{ #if: {{{5|}}}|< [[:{{NAMESPACE}}:{{{5|Main Page}}}|{{ #if: {{{6|}}}|{{{6}}}|{{{5|Main Page}}} }}]] }} {{ #if: {{{7|}}}|< [[:{{NAMESPACE}}:{{{7|Main Page}}}|{{ #if: {{{8|}}}|{{{8}}}|{{{7|Main Page}}} }}]] }}</ul></small></div>
The code is a bit of a mess, so here's the separate parts:
- <div...><small>
- Formatting
- Back to:<br>
- Creates the top "Back to:" part
- <ul>
- This tag is used to indent the links (<p> and colon don't work)
- [[:{{NAMESPACE}}:{{{1|Main Page}}}|{{ #if: {{{2|}}}|{{{2}}}|{{{1|Main Page}}} }}]]
- This is the first link and hypertext
- :{{NAMESPACE}}:{{{1|Main Page}}}
- Link to first parameter, or Main Page if first parameter is undefined
- {{ #if: {{{2|}}}|{{{2}}}|{{{1|Main Page}}} }}
- Hypertext - uses 2nd parameter if defined, 1st if 2nd is undefined or empty and 1st parameter is defined, Main Page if neither 1st or 2nd parameter is defined
- Note that the test for the If statement includes a default empty string - this is because an undefined parameter would return true and only empty strings return false (see this page for the trick)
- Hypertext - uses 2nd parameter if defined, 1st if 2nd is undefined or empty and 1st parameter is defined, Main Page if neither 1st or 2nd parameter is defined
- " "
- Space for the next carot
- {{ #if: {{{3|}}}|< [[...]]}}
- If there is a third parameter, then render the link and hypertext of the 2nd Back Article
- "< "
- Note that this isn't " < " - the space before the carot doesn't show up (hence the space above)
- [[:{{NAMESPACE}}:{{{3|Main Page}}}|{{ #if: {{{4|}}}|{{{4}}}|{{{3|Main Page}}} }}]]
- The link and hypertext for the 2nd Back Article - breaks down like the first one
- :{{NAMESPACE}}:{{{3|Main Page}}}
- Link - note it uses the 3rd parameter instead of the 1st
- {{ #if: {{{4|}}}|{{{4}}}|{{{3|Main Page}}} }}
- Hypertext - note it uses the 3rd and 4th parameters instead of the 1st and 2nd
- Repeat for the each back articles
- Close up the formatting (</ul></small></div>)