+ Reply to Thread
Results 1 to 19 of 19

Thread: How To Implement A Random / Rotating Banner

  1. #1
    vBFAQ Adminstrator Joeychgo has disabled reputation Joeychgo's Avatar
    Join Date
    Jan 2005
    Location
    Chicago, IL
    Age
    43
    Posts
    6,408
    Blog Entries
    2

    Default How To Implement A Random / Rotating Banner

    Many people ask how they can use multiple header banners and have them change with every page view. There are many ways to do this. Here is a simple method.


    Enable Your Plugin System
    You need to use a plugin for this, so first make sure your plugin system is enabled:
    Admin CP -> vBulletin Options -> Plugin/Hook System -> Enable Plugin/Hook System
    Create New Plugin
    Now create a new plugin for the parse_templates hook location:
    Admin CP -> Plugin System -> Add New Plugin
    Use this PHP code in the plugin:
    PHP Code:
    $random_number rand(15);
    $random_banner[1] = '<a href="http://www.link1.com/"><img src="path/to/banner1.gif" alt="" border="0" /></a>';
    $random_banner[2] = '<a href="http://www.link2.com/"><img src="path/to/banner2.gif" alt="" border="0" /></a>';
    $random_banner[3] = '<a href="http://www.link3.com/"><img src="path/to/banner3.gif" alt="" border="0" /></a>';
    $random_banner[4] = '<a href="http://www.link4.com/"><img src="path/to/banner4.gif" alt="" border="0" /></a>';
    $random_banner[5] = '<a href="http://www.link5.com/"><img src="path/to/banner5.gif" alt="" border="0" /></a>'
    The blue numbers represent the range of random numbers to be generated, or the number of banners you have in your rotation. You need to edit the top two numbers appropriately, and then create a $random_banner[X] line for each number in the range. In the above code, the random number is between 1 and 5, inclusive, and there are five banners defined.
    Change the red code appropriately for each banner. You can have each banner link to a different part of your site if you like or all to the same link.
    Display The Banner
    Use this code in any template to display the random banner:
    PHP Code:
    $random_banner[$random_number
    The header template is a common place to insert banners:
    Admin CP -> Styles & Templates -> Style Manager -> Common Templates (in the menu) -> header
    Replace the BOLD code:


    HTML Code:
    <!-- logo -->
    <a name="top"></a>
    <table border="0" width="$stylevar[outertablewidth]" cellpadding="0" cellspacing="0" align="center">
    <tr>
    <td align="$stylevar[left]"><a href="$vboptions[forumhome].php$session[sessionurl_q]"><img src="$stylevar[titleimage]" border="0" alt="$vboptions[bbtitle]" /></a></td>
    <td align="$stylevar[right]">
    &nbsp;
    </td>
    </tr>
    </table>
    <!-- /logo -->
    <!-- content table -->
    $spacer_open
    $_phpinclude_output


    ...with:
    PHP Code:
    $random_banner[$random_number




    Calling Specific Banners
    You can call a specific banner in the templates by using that banner's number. For example:
    PHP Code:
     $random_banner[3
    Last edited by Joeychgo; 12-08-2006 at 12:23 PM.

  2. #2

    Default

    Very useful mod, thanks.

  3. #3
    Intermediate vBulletin User NickT'sGTP is on a distinguished road NickT'sGTP's Avatar
    Join Date
    Sep 2006
    Location
    Cedar Rapids, IA
    Age
    25
    Posts
    64

    Default

    You say replace the BOLD code....but I don't see anything bold. It's either blue or red.

    Also, how would I get it to lets say...rotate a 468 x 80 banner size, in the area I have noted in this picture:



    Is there some sort of like <align right> code I have to do....? If so where?

  4. #4
    vBFAQ Adminstrator Joeychgo has disabled reputation Joeychgo's Avatar
    Join Date
    Jan 2005
    Location
    Chicago, IL
    Age
    43
    Posts
    6,408
    Blog Entries
    2

    Default

    Fixed the BOLD code.

    There are alot of ways to do what you ask - One way would be to make 2 tables for the header - one on the left one on the right.

  5. #5
    Experienced vBulletin User popowich is on a distinguished road popowich's Avatar
    Join Date
    Dec 2006
    Location
    Rochester, New York
    Posts
    972

    Default

    Is this a creative alternative to something like phpAdsNew so you don't have to worry about that staying up to date? Also, do you know offhand if this is a FIX for Norton Security. I use phpAdsNew myself, but Norton Security users don't see my ads since they get blocked by that software, and maybe others I don't know about yet.

    -Raymond

  6. #6
    vBFAQ Adminstrator Joeychgo has disabled reputation Joeychgo's Avatar
    Join Date
    Jan 2005
    Location
    Chicago, IL
    Age
    43
    Posts
    6,408
    Blog Entries
    2

    Default

    This is a simple banner rotater. It could be used for ad banners, or header banners, among other things. PHPadsnew is a whole ads management system.

  7. #7
    Experienced vBulletin User minstrel is on a distinguished road minstrel's Avatar
    Join Date
    Jan 2005
    Location
    Ottawa, Canada
    Posts
    1,479

    Default

    You can also accomplish this with the vB Ad Management hack or the vB Banner Rotator hack.
    Last edited by minstrel; 12-08-2006 at 10:14 PM.

  8. #8
    Intermediate vBulletin User NickT'sGTP is on a distinguished road NickT'sGTP's Avatar
    Join Date
    Sep 2006
    Location
    Cedar Rapids, IA
    Age
    25
    Posts
    64

    Default

    Sweet, I installed this tonight. Works like a charm. And it's easy to add banners into it. Before I had to run through the whole process of taking banners into photoshop, and imageready and animating them, and then saving them as a GIF and then compressing them. And then loading them up into the FTP, and then adding code into the template and blah blah blah....this is much easier.

  9. #9
    vBFAQ Adminstrator Joeychgo has disabled reputation Joeychgo's Avatar
    Join Date
    Jan 2005
    Location
    Chicago, IL
    Age
    43
    Posts
    6,408
    Blog Entries
    2

    Default

    Yup - this is very easy and simple.

  10. #10
    Intermediate vBulletin User NickT'sGTP is on a distinguished road NickT'sGTP's Avatar
    Join Date
    Sep 2006
    Location
    Cedar Rapids, IA
    Age
    25
    Posts
    64

    Default

    Is there code I can add/replace to get it to where the banners rotate every ten seconds or so?

  11. #11

    Default

    very thanks
    super a mod

  12. #12

    Default

    Can this be used with adsense/shoppingads code, and if so, how?

  13. #13

    Default

    Awesome.... works perfectly. However, what's the trick to make it happen with my title image?

    EDIT: Nevermind... got it.

  14. #14

    Default

    This does not seem to work. I did exactly what was said to do and put the code in my navbar and nothing happens.

    Any help would be great. I have installed many modules in the past and this one just didn't work at all.

  15. #15
    vBFAQ Adminstrator Joeychgo has disabled reputation Joeychgo's Avatar
    Join Date
    Jan 2005
    Location
    Chicago, IL
    Age
    43
    Posts
    6,408
    Blog Entries
    2

    Default

    Well, works for everyone else.... Go back and make certain you did everything.

  16. #16

    Default

    Quote Originally Posted by Joeychgo View Post
    Fixed the BOLD code.

    There are alot of ways to do what you ask - One way would be to make 2 tables for the header - one on the left one on the right.
    Hello,

    First, let me say i apologize for upping a thread from 2 years ago but i didn't find an answer for my problem and i didn't wanted to open a new thread,

    I have the same problem, i want to add aother image to the header of my forum,
    i'm new to php and vb, how do i add another table? the rotating gif i can make with gif animator or such, and on that note, lets say i want 3 images, how do i center the main logo and put an image in each side of it?

    I know how to edit templates and use the admincp, just need some direction,

    Thanks a million,

    Erez.

  17. #17

    Default

    Quote Originally Posted by ewolf View Post
    lets say i want 3 images, how do i center the main logo and put an image in each side of it?
    Just make the table row three columns wide. Your basic structure would be:

    HTML Code:
    <table>
    <tr>
    <td> left hand content </td>
    <td> center content </td>
    <td> right hand content </td>
    </tr>
    </table>

  18. #18

  19. #19
    Experienced vBulletin User C138 Kaysone is on a distinguished road C138 Kaysone's Avatar
    Join Date
    Jan 2008
    Location
    North Carolina
    Age
    20
    Posts
    338

    Default

    I wish there was a simple mod like this instead of doing alot of editing lol, i feel stupid when it comes to this.. plus to monitor the views and clicks

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Rotating ads
    By qryztufre in forum Other ways to Make Money with your vBulletin Forum
    Replies: 4
    Last Post: 01-19-2009, 10:27 PM
  2. What could vB possiblely implement in v4?
    By Big Dan in forum vBulletin Discussion and Questions
    Replies: 15
    Last Post: 07-01-2007, 10:53 AM
  3. how much to cahrge for rotating banner?
    By friscogal in forum Other ways to Make Money with your vBulletin Forum
    Replies: 1
    Last Post: 09-13-2006, 02:49 PM
  4. vBulletin Hack: A Simple Random Banner Rotator
    By Joeychgo in forum Hack Discussion and Requests
    Replies: 6
    Last Post: 08-03-2006, 10:38 PM
  5. Rotating ads
    By johnscanlan in forum Setting up and Customizing your Forum
    Replies: 3
    Last Post: 09-17-2005, 03:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts