FANDOM


  • So I'm working on a template for one wiki (http://witcher.wikia.com/wiki/Template:Canon_Tabs) and I'd like to make it as versatile as possible. For instance, we have some characters that only appear in the books, some only in the games, and some in both, and some may get an additional quotes page. I want to be able to hide the tabs if they don't apply to the character (assume this will be used only on pages that will use at least 2 of the tabs). I tried to use if expression like I did with an infobox, but the template didn't appear to like that. Is there something else I can do to be able to turn on/off certain tabs?

    Note: yes, I know they're not really tabs, but this is the only way I know how to set it up so those on desktop see the tabs while those on mobile would also see links to the subpages as actual tabs don't really work well with mobile.

      Loading editor
    • Would it be okay to hide the tab if the page doesn't exist? Some wikitext logic would easily do that.

      (About your note: it's good fallback markup from a portability perspective. Nice one.)

        Loading editor
    • If hiding the tab when the page doesn't exist is fine with you:

      <div class="canontabs"><p style="display: none;">Related Pages:</p><!--
       --><ul><!--
           -->{{#ifexist: {{BASEPAGENAME}} |<li>[[{{PAGENAME}}|<span>Books</span>]]</li>}}<!--
           -->{{#ifexist: {{BASEPAGENAME}}/Games |<li>[[{{PAGENAME}}/Games|<span>Games</span>]]</li>}}<!--
           -->{{#ifexist: {{BASEPAGENAME}}/Quotes |<li>[[{{PAGENAME}}/Quotes|<span>Quotes</span>]]</li>}}<!--
       --></ul>
      </div>
      
        Loading editor
    • Sure, that'd work just fine. Question though: is there an easy way to make it so the main page could be either the books or games? Some are only game characters so they wouldn't always have a book page. (Basically, some "Game" pages will actually be the main article page).

        Loading editor
    • (Hmm, it appears the correct parameter is {{BASEPAGENAME}}. I notice you fixed it too. 👍︎)

      Let's see.

      <div class="canontabs"><p style="display: none;">Related Pages:</p><!--
       --><ul><!--
           -->{{#ifeq:{{{main|books}}}|games<!--
              -->|{{#ifexist: {{BASEPAGENAME}}/Games |<li>[[{{PAGENAME}}/Games|<span>Games</span>]]</li>}}<!--
               -->{{#ifexist: {{BASEPAGENAME}} |<li>[[{{BASEPAGENAME}}|<span>Books</span>]]</li>}}<!--
              -->|{{#ifexist: {{BASEPAGENAME}} |<li>[[{{BASEPAGENAME}}|<span>Books</span>]]</li>}}<!--
               -->{{#ifexist: {{BASEPAGENAME}}/Games |<li>[[{{BASEPAGENAME}}/Games|<span>Games</span>]]</li>}}<!--
           -->}}<!--
           -->{{#ifexist: {{BASEPAGENAME}}/Quotes |<li>[[{{BASEPAGENAME}}/Quotes|<span>Quotes</span>]]</li>}}<!--
       --></ul>
      </div>
      

      Then {{Canon Tab|main=games}} for game only characters. Defaults to book-first characters with {{Canon Tab}}.

        Loading editor
    • That'll work, thanks so much!

        Loading editor
    • it will generate 3 wanted pages per usage. i'd suggest to use dpl for that.

        Loading editor
    • I bypass wanted page issue with {{#ifexist}} function. Expensive iirc, but effective.

        Loading editor
    • Doesn't #ifexist cause the pages to be listed as wanted? Or did they fix that bug?

        Loading editor
    • Speedit#8
      I bypass wanted page issue with {{#ifexist}} function

      u did not.
      Andrewds1021#9
      Doesn't #ifexist cause the pages to be listed as wanted?

      it will never fixed, i guess.

      code: {{#ifexist:fngplg|fng|plg}}

      result:plg Special:WhatLinksHere/fngplg

        Loading editor
    • So it is as I thought then.

        Loading editor
    • Ah my bad - I assumed that bug got fixed. What would the DPL solution be? (In the interest of not making maintenance at w:c:witcher a lot harder.)

        Loading editor
    • i do use this:
      {{#dpl:debug=0|allowcachedresults=1|mode=userformat|ordermethod=titlewithoutnamespace|count=1|namespace=|title={{BASEPAGENAME}}/Quotes|format=,[[:%PAGE%|'''Quotes''']],}}
      
        Loading editor
    • Ok, and where would that go exactly?

      As a side note, to also avoid that bug, would it be possible to add more user input like the main tab switch between books and games but instead would only create a tab if the user said yes?

        Loading editor
    • It would replace the corresponding #ifexist; however, I think you would need to enclose the link in li tags.

      Yes, you could have the user manually indicate whether or not to display the tab.


      @Fngplg

      Have you tested it to know that allowcachedresults works with inputs other than those explicitly listed in the documentation?

        Loading editor
    • Andrewds1021#15
      Have you tested it to know that allowcachedresults works with inputs other than those explicitly listed in the documentation?

      idk how to test it properly. according to src code, it accepts either of 'true', 'yes', '1' and 'on' as true.
        Loading editor
    • Okay, well, I don't see a reason it wouldn't then. I was just asking because those alternative aren't mentioned in the manual.

        Loading editor
    • A FANDOM user
        Loading editor
Give Kudos to this message
You've given this message Kudos!
See who gave Kudos to this message