Template:randommainpage
From Homestar Runner Wiki
(Difference between revisions)
(let's add this) |
(→Usage: better wording) |
||
(includes 7 intermediate revisions) | |||
Line 1: | Line 1: | ||
- | <includeonly> | + | <includeonly>{{#setvar: Total_Main_Pages | {{#expr: |
- | + | {{#if:{{{oldhr|}}}| | |
- | 3 <!-- number of special main pages; see list below --> |show}} }} | + | 26 <!-- number of regular main pages on the Flash archive -->| |
+ | 27 <!-- number of regular main pages -->}} + {{#setvar: Special_Main_Pages | | ||
+ | 3 <!-- number of special main pages; see list below --> |show}} }} | ||
}}{{#switch: {{#setvar: Get_Main_Page | {{#rand: {{#var:Total_Main_Pages}} }} |show|check}} | }}{{#switch: {{#setvar: Get_Main_Page | {{#rand: {{#var:Total_Main_Pages}} }} |show|check}} | ||
Line 11: | Line 13: | ||
| 3 = mainking | | 3 = mainking | ||
- | | <!-- default --> main{{#expr: {{#var:Get_Main_Page}} - {{#var:Special_Main_Pages}} | + | | <!-- default --> main{{#expr: {{#var:Get_Main_Page}} - {{#var:Special_Main_Pages}} }} |
- | }}</includeonly><noinclude>Returns the filename of a random main page, including the special main pages. | + | }}</includeonly><noinclude>Returns the filename of a random main page, including the special main pages (with the exception of the [[Strong Bad Main Page]], which doesn't have its own URL). |
The same value is returned for every instance of the template on a given page (the template only chooses a random number once per page). | The same value is returned for every instance of the template on a given page (the template only chooses a random number once per page). | ||
Line 18: | Line 20: | ||
===Usage=== | ===Usage=== | ||
*<code><nowiki>{{randommainpage}}</nowiki></code>: {{randommainpage}} | *<code><nowiki>{{randommainpage}}</nowiki></code>: {{randommainpage}} | ||
+ | *<code><nowiki>{{randommainpage|oldhr=true}}</nowiki></code>: {{randommainpage|oldhr=true}} ''(excludes any main pages after [[Main Page 26|26]])'' | ||
*<code><nowiki>[[HR:{{randommainpage}}.html]]</nowiki></code>: [[HR:{{randommainpage}}.html]] | *<code><nowiki>[[HR:{{randommainpage}}.html]]</nowiki></code>: [[HR:{{randommainpage}}.html]] | ||
Line 24: | Line 27: | ||
*To add a special main page, increment the appropriate number and add the filename to the lower list. | *To add a special main page, increment the appropriate number and add the filename to the lower list. | ||
- | [[Category: | + | [[Category:Link Box Templates|{{PAGENAME}}]]</noinclude> |
Current revision as of 10:26, 6 January 2022
Returns the filename of a random main page, including the special main pages (with the exception of the Strong Bad Main Page, which doesn't have its own URL).
The same value is returned for every instance of the template on a given page (the template only chooses a random number once per page).
[edit] Usage
{{randommainpage}}
: main23{{randommainpage|oldhr=true}}
: main23 (excludes any main pages after 26)[[HR:{{randommainpage}}.html]]
: HR:main23.html
[edit] To update
- Increment the number of regular main pages whenever a new one is added.
- To add a special main page, increment the appropriate number and add the filename to the lower list.