FANDOM


  • This is a bit complex, so I'll do my best to explain what I want.

    So on multiple pages of my wikia, http://we-are-daisy.wikia.com/wiki/We_Are_Daisy_Wikia we have Trivia sections at the bottom. What I wanted to do was to integrate those trivia points on to the MAIN home page in a manner such that there would be 1 different trivia point that appears on the main page once a week.

    Are there any codes to help with this, or would I have to manually copy and paste and manually change it every week? Alternatively, are there any codes that can give a different trivia point per every refresh? How would I update the list of selection options it has to chose from? Thank you!

      Loading editor
    • Hmm... the once a week thing makes it trickier. If you would be okay with it changing every page visit, it would be much easier. Once a week would require Javascript in all likelihood (or Lua).

        Loading editor
    • could you explain how to let it change every page visit? and how to update the list it can pull from, if possible?


      Specifically, retrieving any 1 random point from the trivia section of any page

        Loading editor
    • ElexorienBot
      ElexorienBot removed this reply because:
      mistake
      07:41, February 13, 2016
      This reply has been removed
    • There are multiple ways to do this.

      Add this to your Wikia.js:

      this.randomtip = function(){
      	var length = $("#tips li").length;
      	var ran = Math.floor(Math.random()*length) + 1;
      	$("#tips li:nth-child(" + ran + ")").show();
      };
       
      $(document).ready(function(){	
      	randomtip();
      });


      Add this to your Wikia.css:

      #tips li{
      	display:none;
      	list-style: none;
      	}


      Then, in a template titled Template:RandomTrivia or something like that, add this:

      <ul id="tips">
      	<li> TRIVIA HERE </li>
      	<li> TRIVIA HERE </li>
      	<li> TRIVIA HERE </li>
      	<li> TRIVIA HERE </li>
      	<li> TRIVIA HERE </li>
      </ul>
      

      You can add how ever many trivia facts you want.

      On the main page you would type {{RandomTrivia}}.

        Loading editor
    • An easier method would be to use <choose> and <option> tags.

      ===Did you know...===
      *<choose>
      <option>...that [fact 1]?</option>
      <option>...that [fact 2]?</option>
      <option>...that [fact 3]?</option>
      <option>...that [more facts]?</option>
      <option>...that [fact n]?</option>
      </choose>
      

      would give:

      Did you know...

      • ...that [more facts]?

      More info here.

        Loading editor
    • Slyst wrote:

      An easier method would be to use <choose> and <option> tags.

      ===Did you know...===
      *<choose>
      <option>...that [fact 1]?</option>
      <option>...that [fact 2]?</option>
      <option>...that [fact 3]?</option>
      <option>...that [more facts]?</option>
      <option>...that [fact n]?</option>
      </choose>
      

      would give:

      Did you know...

      • ...that [fact 3]?

      More info here.

      Had no idea that existed >_<

        Loading editor
    • So both options would require me to manually put in new options by hand? Is there an option that automatically updates its pool of options as we add more trivia sections per page?

        Loading editor
    • Uh how are you inserting the trivia on the pages? Just typing them in plain text?

      There probably is a way for that, but I don't see why it's necessarily needed.

      You could fill the options with like 50+ facts so that there is a low chance for it to be repeated. You can also keep adding to the list as time goes by.

        Loading editor
    • Yeah, pretty much just typing in plain text as i think of new ones. haha, okay thanks all. looks like i'll suffer the long way

        Loading editor
    • Michaeloll wrote: So both options would require me to manually put in new options by hand? Is there an option that automatically updates its pool of options as we add more trivia sections per page?

      Anything automatic is likely to be much more complicated and require Javascript.

        Loading editor
    • It depends on how each week is defined, for example, if one wants it to change on the 7 , 14, 21, and 28 it could be as simple as writing:

      {{#ifeq:{{#expr:{{CURRENTDAY}} mod 7}}|0
      |Show random new trivia
      |Show trivia 8
      }}

      The problem is that mediawiki is designed for performance. That means that the cache won't change when one wants it to. So it may show a new trivia later than one would expect, or simply skip the check because the cache wasn't reset in a particular day. The only true way to prevent this behavior is using JavaScript or by using something like the <choice> shown above to force it to check every time. Although if I recall correctly cache still affects the "choice thing".

      Side Note: Extensions like choice should really be killed in Wikia, because 1) they affect performance, 2) Wikitext is not a programming language nor will it likely ever be.

        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