Template:Bc
Revision as of 14:25, 7 January 2009 by imported>SnakeChomp (Replace free standing < characters with <)
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>)