Random Banner for vB 3.6?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • boogie box high
    Senior Member
    • Jul 2004
    • 200
    • 3.6.x

    Random Banner for vB 3.6?

    Hello,

    just curious if this code works on vb3.6?



    Thank you
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    #2
    It should work exactly the same in 3.6.

    Comment

    • Goldoff
      New Member
      • Oct 2005
      • 18
      • 3.5.x

      #3
      It does, but I am trying to make it with three banners simultaneously.

      I mean, How to have three rotating, non repeating-at-same-time banners in the same page?

      Something like this:



      I've tried putting two more identical plugins (with the same banners) and changing the

      PHP Code:
       $random_banner[$random_number
      for

      PHP Code:
       $random_banner[$random_number2
      and

      PHP Code:
       $random_banner[$random_number3
      But sometimes I get even three identical banners...

      Thank you in advance.
      Last edited by Goldoff; Wed 1 Nov '06, 2:17pm.

      Comment

      • Jake Bunce
        Senior Member
        • Dec 2000
        • 46598
        • 3.6.x

        #4
        You can modify the code to prevent identical random numbers. For help with this you should post on www.vbulletin.org.

        Comment

        • feldon23
          Senior Member
          • Nov 2001
          • 11291
          • 3.7.x

          #5
          EDIT: CORRECTED to provide 3 distinct numbers.

          Code:
          $random_number1 = rand(1, 5);
          
          do {
          $random_number2 = rand(1, 5);
          } while ($random_number2 == $random_number1);
          
          do {
          $random_number3 = rand(1, 5);
          } while (($random_number3 == $random_number1) or ($random_number3 == $random_number2));
          Last edited by feldon23; Fri 3 Nov '06, 1:24pm.

          Comment

          • Goldoff
            New Member
            • Oct 2005
            • 18
            • 3.5.x

            #6
            Wow

            Originally posted by feldon23
            $random_number1 = rand(1, 5);

            do {
            $random_number2 = rand(1, 5);
            } while ($random_number2 != $random_number1);

            do {
            $random_number3 = rand(1, 5);
            } while (($random_number3 != $random_number1) && ($random_number3 != $random_number2));

            Hi Feldon,

            (oops, and hi Jake too)

            Thanks for your help, but...

            When I pasted that code replacing the

            PHP Code:
            $random_banner[$random_number


            and the other two, the board just stopped working and I was unable to access the cp nor the board itself: Lots of "Fatal errors"...

            Fortunately, I was working with the test one. Re-installing the whole thing.

            What I did wrong?

            Again, thank you for your time

            Comment

            • feldon23
              Senior Member
              • Nov 2001
              • 11291
              • 3.7.x

              #7
              You cannot paste a bunch of PHP code into a template!

              My instructions were to add to the Plugin. Then in your template, you can use $random_banner[$random_number1], $random_banner[$random_number2], and $random_banner[$random_number3].

              If a Plugin causes problems, you can disable plugins in the /includes/config.php file. No need to reinstall vBulletin.
              Last edited by feldon23; Fri 3 Nov '06, 6:15am.

              Comment

              • Goldoff
                New Member
                • Oct 2005
                • 18
                • 3.5.x

                #8
                Sorry, it took me forever to make it working because I forgot to enable the plugin system after re-installing...

                Well, the fact is that it is working now... but there are three equal banners each time:



                no matter how many times I refresh...

                This time I did what you said: added your whole code to the plugin (just one) and put in the template

                $random_banner[$random_number1]
                $random_banner[$random_number2]
                and

                $random_banner
                [$random_number3]



                Don't know what went wrong this time...


                I do appreciate your patience.

                Comment

                • feldon23
                  Senior Member
                  • Nov 2001
                  • 11291
                  • 3.7.x

                  #9
                  Ok, how did I miss that?!

                  This is the correct code, I promise:
                  Code:
                  $random_number1 = rand(1, 5);
                  
                  do {
                  $random_number2 = rand(1, 5);
                  } while ($random_number2 == $random_number1);
                  
                  do {
                  $random_number3 = rand(1, 5);
                  } while (($random_number3 == $random_number1) or ($random_number3 == $random_number2));

                  Comment

                  • Goldoff
                    New Member
                    • Oct 2005
                    • 18
                    • 3.5.x

                    #10
                    Feldon, you are GREAT!!




                    It is working per-fect

                    Thank you SO much for your help

                    Best regards

                    Comment

                    • feldon23
                      Senior Member
                      • Nov 2001
                      • 11291
                      • 3.7.x

                      #11
                      I always get confused by double-negatives.

                      Comment

                      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                      Working...