Difference between revisions of "Template:Season"
Jump to navigation
Jump to search
Margotbean (talk | contribs) (lowercase correction) |
(Revamp using new helper templates. Plus handles recursion, takes multiple seasons to create bullet-separated list, etc.) |
||
Line 1: | Line 1: | ||
− | <includeonly>< | + | <includeonly><!-- |
− | | | + | |
− | | | + | // Define the allowed values. Handling multiple quirks/oddities. Ideally, all of the names would work equally well |
− | | | + | // as displayed text, wiki page names, and icon names. But that's not possible. So top priority is to |
− | | | + | // create a list of valid page names. That's why 'Seasons' is primary name for 'All', 'Any', 'All Seasons' |
− | | | + | // Marriage, Deviations are for sake of NPC schedule sections (and translations) |
− | | | + | -->{{#arraydefine:$engl_seasons|Spring, Summer, Fall, Winter, Seasons, Marriage, Deviations, Fall, Seasons, Seasons}}<!-- |
− | | | + | -->{{#arraydefine:$lang_seasons|Spring, Summer, Fall, Winter, Seasons, Marriage, Deviations, Autumn, All, Any}}<!-- |
− | |{{ | + | -->{{#arraydefine:$lang_allshort | All }}<!-- |
+ | -->{{#arraydefine:$lang_alllong | All Seasons}}<!-- | ||
+ | |||
+ | // END OF translated text | ||
+ | |||
+ | // Check whether there's already a file link in {{{1}}}... implying this is probably a recursive call. Return immediately | ||
+ | -->{{#if:{{#pos:{{{1|}}}|<nowiki>[[File</nowiki>}}|{{{1}}}|<!-- | ||
+ | // Parse input data, then loop over all extracted entries | ||
+ | -->{{#arraydefine:$sseason|{{ParseInputValues|{{{1|}}}|{{#arrayprint:$engl_seasons}}|{{#arrayprint:$lang_seasons}}|default=true}}}}<!-- | ||
+ | -->{{#if:{{#arrayprint:$sseason}} | | ||
+ | <span style="display:inline; margin-right:0;"><!-- | ||
+ | -->{{#arrayprint:$sseason||@season@|<!-- | ||
+ | |||
+ | // Add space and bullet if this is not first entry | ||
+ | -->{{#ifexpr:{{#arraysearch:$sseason|@season@}}>0| • }}<!-- | ||
+ | |||
+ | // Convert @season@ (english page name) into translated page name | ||
+ | -->{{#arraydefine:$slink_text|{{#arrayindex:$lang_seasons|{{#arraysearch:$engl_seasons|@season@}}}}}}<!-- | ||
+ | |||
+ | // Display the non-icon, non-linkable cases: Devations, and unmatched text (detected by empty link_text) | ||
+ | // This is also how text_only option is handled | ||
+ | -->{{#ifeq:{{#arrayprint:$slink_text}}| | ||
+ | | {{ucfirst:@season@}} | ||
+ | | {{#ifexpr: {{#ifeq:@season@|Deviations|1|0}} or {{#if:{{{text_only|}}}|1|0}} | ||
+ | | {{#if:{{{no_translate|}}}|@season@|{{#arrayprint:$slink_text}}}} | ||
+ | | <!-- | ||
+ | |||
+ | // Display the normal cases: first display icon | ||
+ | -->[[File:{{#switch:@season@ | ||
+ | |Spring | ||
+ | |Summer | ||
+ | |Fall | ||
+ | |Winter = @season@ | ||
+ | |Seasons = All_Seasons_Icon | ||
+ | |Marriage = Mermaid's Pendant | ||
+ | }}.png | {{{width|24px}}} | link={{#arrayprint:$slink_text}} | alt={{#arrayprint:$slink_text}}]] <!-- | ||
+ | |||
+ | // Add link, with special treatment for text of All Seasons | ||
+ | -->[[{{#arrayprint:$slink_text}}|<!-- | ||
+ | -->{{#ifeq:@season@|Seasons | ||
+ | |{{#if:{{{do_short|}}}|{{#arrayprint:$lang_allshort}}|{{#arrayprint:$lang_alllong}}}} | ||
+ | |{{#arrayprint:$slink_text}}}}]]<!-- | ||
+ | -->}}}}}}</span>}}}}</includeonly><noinclude>{{Englishdoc}}{{#ifexist:{{FULLPAGENAME}}/doc |<nowiki/> | ||
+ | {{{{FULLPAGENAME}}/doc}} }}</noinclude> |
Revision as of 23:56, 3 September 2020
Description
This template displays the icon for the requested season, plus the season as a link to its associated article.
Notes
The template recognizes two special values of season, Marriage and Deviations, for the sake of NPC schedule pages (see Template:ScheduleHeader).
Use
{{Season|name of season|day (optional)|width (optional)}}
Examples
{{Season|Spring}} {{Season|Marriage}} {{Season|Deviations}} {{Season|All|width=48}} {{Season|Summer|24}}
Results:
Template:ParseInputValues
Template:ParseInputValues
Template:ParseInputValues
Template:ParseInputValues
Template:ParseInputValues