Module:FindYDCportal/doc
Appearance
![]() | This is a documentation subpage for Module:FindYDCportal. It may contain usage information, categories and other content that is not part of the original module page. |
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.
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
- for "Portal:19th century" return
19th century
If no portal is found, it returns an empty string.
Usage
{{#invoke: FindYDCportal | main |YYYY}}
Examples
- Years
{{#invoke: FindYDCportal | main |2018}}
→ Script error: The function "main" does not exist.{{#invoke: FindYDCportal | main |1935}}
→ Script error: The function "main" does not exist.{{#invoke: FindYDCportal | main |1857}}
→ Script error: The function "main" does not exist.{{#invoke: FindYDCportal | main |736}}
→ Script error: The function "main" does not exist.{{#invoke: FindYDCportal | main |1800}}
→ Script error: The function "main" does not exist.
- Decades
{{#invoke: FindYDCportal | main |2000s}}
→ Script error: The function "main" does not exist.{{#invoke: FindYDCportal | main |1940s}}
→ Script error: The function "main" does not exist.{{#invoke: FindYDCportal | main |560s}}
→ Script error: The function "main" does not exist.
- Missing parameter
{{#invoke: FindYDCportal | main}}
→ Script error: The function "main" does not exist.
- Empty parameter
{{#invoke: FindYDCportal | main | }}
→ Script error: The function "main" does not exist.
- Invalid parameter
{{#invoke: FindYDCportal | main | 1927-related}}
→ Script error: The function "main" does not exist.{{#invoke: FindYDCportal | main | Swedish chef}}
→ Script error: The function "main" does not exist.
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