Template talk:Vacation3

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

{{GENDER}} magic word[edit]

Would it be a good idea to incorporate the {{GENDER}} magic word into this template? I had a look at it, and I think it might be doable, but I'm still only a bare beginner at templates (anything more than a simple {{{1}}} is still a big accomplishment for me <g>), and I'm not sure enough of what I'm doing to try making the change myself. --RobinHood70 (talk) 21:09, 7 August 2009 (UTC)[reply]

checkY Done. Amalthea 21:50, 7 August 2009 (UTC)[reply]
Excellent, thanks Amalthea! Looking at what you've done, that's well beyond what I could've done...but I'll study it and see if I can figure it out as part of my learning process. Thanks again. --RobinHood70 (talk) 22:00, 7 August 2009 (UTC)[reply]
Yeah, it's a bit more difficult than one would presume:
  • For the magic word, we need the name of the user. We don't require passing it in though, so we want to figure it out by the page we are on. Since subpages confuse the magic word and the template is used on e.g. User:Jamesontai/Archives/UserpageArchive25DEC2007 we need to use {{FULLROOTPAGENAME}}, i.e.:
    {{gender:{{FULLROOTPAGENAME}} | m | f | }}
  • Furthermore, if used on any page other than a User or User talk page, e.g. on Wikipedia:RobinHood70, it would get confused as well, so we only use the magic word in those namespaces:
    {{#switch:{{NAMESPACE}} | {{ns:User}} | {{ns:User talk}} = {{gender:{{FULLROOTPAGENAME}}|m|f|}} }}
  • In any case, if a user passed a "gender" parameter explicitly, we'll want to give that priority, and only fall back on the magic word:
    {{{gender | {{#switch:{{NAMESPACE}}|{{ns:User}}|{{ns:User talk}}={{gender:{{FULLROOTPAGENAME}}|m|f|}}}} }}}
  • We also want to allow passing "M" or "F", so we convert the gender parameter to lowercase:
    {{lc: {{{gender|{{#switch:{{NAMESPACE}}|{{ns:User}}|{{ns:User talk}}={{gender:{{FULLROOTPAGENAME}}|m|f|}}}}}}} }}
  • And lastly, switch on the combined evaluation of parameter and magic word:
    {{#switch: {{lc:{{{gender|{{#switch:{{NAMESPACE}}|{{ns:User}}|{{ns:User talk}}={{gender:{{FULLROOTPAGENAME}}|m|f|}}}}}}}}} | m=He | f=She | #default=He or she }}
Cheers, Amalthea 22:36, 7 August 2009 (UTC)[reply]
Wow, thanks for the explanation! --RobinHood70 (talk) 23:08, 7 August 2009 (UTC)[reply]