Difference between revisions of "Template:FindYDCportal/doc"
imported>BlackcurrantTea (→Output: rm example linking to deleted portal) |
imported>Timrollpickering m (→See also: emove Category:WGUserboxes per Wikipedia:Categories for discussion/Log/2020 September 29, replaced: Portal templates → Portal namespace templates) |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
{{Documentation subpage}} | {{Documentation subpage}} | ||
{{Lua|Module:FindYDCportal}} | {{Lua|Module:FindYDCportal}} | ||
| + | {{High use|41147 }} | ||
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | ||
A helper template to find the most specific chronology portal which actually exists for a given year or decade. Used to simplify linking to a chronology portal. | A helper template to find the most specific chronology portal which actually exists for a given year or decade. Used to simplify linking to a chronology portal. | ||
| Line 15: | Line 16: | ||
If a portal is found, returns its name without the namespace prefix, e.g. | If a portal is found, returns its name without the namespace prefix, e.g. | ||
* for "[[Portal:1980s]]" return <code><nowiki>1980s</nowiki></code> | * for "[[Portal:1980s]]" return <code><nowiki>1980s</nowiki></code> | ||
| − | |||
If no portal is found, it returns an empty string. | If no portal is found, it returns an empty string. | ||
| Line 29: | Line 29: | ||
;Years | ;Years | ||
* <code><nowiki>{{FindYDCportal|2018}}</nowiki></code> → {{FindYDCportal |2018}} | * <code><nowiki>{{FindYDCportal|2018}}</nowiki></code> → {{FindYDCportal |2018}} | ||
| − | * <code><nowiki>{{FindYDCportal| | + | * <code><nowiki>{{FindYDCportal|1982}}</nowiki></code> → {{FindYDCportal |1982}} |
| + | * <code><nowiki>{{FindYDCportal|1946}}</nowiki></code> → {{FindYDCportal |1946}} | ||
* <code><nowiki>{{FindYDCportal|1857}}</nowiki></code> → {{FindYDCportal |1857}} | * <code><nowiki>{{FindYDCportal|1857}}</nowiki></code> → {{FindYDCportal |1857}} | ||
* <code><nowiki>{{FindYDCportal|736}}</nowiki></code> → {{FindYDCportal |736}} | * <code><nowiki>{{FindYDCportal|736}}</nowiki></code> → {{FindYDCportal |736}} | ||
| Line 68: | Line 69: | ||
<!-- Categories below this line, please; interwikis at Wikidata --> | <!-- Categories below this line, please; interwikis at Wikidata --> | ||
[[Category:Date-computing templates]] | [[Category:Date-computing templates]] | ||
| − | [[Category:Portal templates]] | + | [[Category:Portal namespace templates]] |
}}</includeonly> | }}</includeonly> | ||
Latest revision as of 10:25, 7 October 2020
| This is a documentation subpage for Template:FindYDCportal. It contains usage information, categories and other content that is not part of the original template page. |
| This template uses Lua: |
| This template is used on approximately 133,000 pages. To avoid major disruption and server load, any changes should be tested in the template's /sandbox or /testcases subpages, or in your own user subpage. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them. Transclusion count updated automatically (see documentation). |
A helper template to find the most specific chronology portal which actually exists for a given year or decade. Used to simplify linking to a chronology portal.
It is a wrapper template around Module:FindYDCportal. For use within templates, it is most efficient to invoke the module directly. For one-off use, the template requires less typing and makes the code easier to read.
Contents
Parameters
Takes one parameter, which must be either a year (e.g. "1879", "1123") or a decade (e.g. "1940s", "730s").
If the parameter is missing, empty, or does not fit the required format, an empty string is returned.
Output
If a portal is found, returns its name without the namespace prefix, e.g.
- for "Portal:1980s" return
1980s
If no portal is found, it returns an empty string.
Usage
- Year parameter
{{FindYDCportal|YYYY}} ... where YYYY is a 3- or 4-digit year
- Decade parameter
{{FindYDCportal|YYY0s}} ... where YYY0s is a 3- or 4-digit decade
Examples
- Years
{{FindYDCportal|2018}}→{{FindYDCportal|1982}}→ Lua error in mw.title.lua at line 311: bad argument #2 to 'title.new' (unrecognized namespace name 'Portal').{{FindYDCportal|1946}}→{{FindYDCportal|1857}}→{{FindYDCportal|736}}→{{FindYDCportal|1800}}→
- Decades
{{FindYDCportal|2000s}}→{{FindYDCportal|1940s}}→{{FindYDCportal|560s}}→
- Missing parameter
{{FindYDCportal}}→
- Empty parameter
{{FindYDCportal|}}→
- Invalid parameter
{{FindYDCportal|1927-related}}→{{FindYDCportal|Swedish chef}}→
Logic
If the parameter is a year:
- If the year portal exists, return its name.
Otherwise try the decade. - If the decade portal exists, return its name.
Otherwise try the century - If the century portal exists, return its name.
Otherwise return an empty string
If the parameter is a decade:
- If the decade portal exists, return its name.
Otherwise try the century - If the century portal exists, return its name.
Otherwise return an empty string
See also