vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   A Simple PHP Banner Rotator? (https://vborg.vbsupport.ru/showthread.php?t=124834)

Ian555 08-24-2006 10:32 PM

A Simple PHP Banner Rotator?
 
I have searched high and low for a simple banner rotator... and have found quite a few options on script sites. I got a few of them working outside of vBulletin without any trouble.

But PLEASE can someone tell me why whenever I place any php code in the header template the board refuses to show anything... when perfectly simple php page in the same directory works fine?

I don't want phpadsnew, I don't want to count clicks or anything, I don't want to use javascript, I just need to integrate stuff that's simple outside of vBulletin into the templates... I followed this to the letter http://www.vbulletin.com/forum/showthread.php?t=170826 and it doesn't work.

I am running the latest version 3.6.0 and I just need to rotate 3 or 4 banners on page refresh... nothing complicated at all outside of vBulletin... but there must be something you guys are not telling about. :)

ANY help appreciated, thanks :)

Ntfu2 08-24-2006 11:18 PM

because you cant parse php in the templates without a modification. Search for the let php live modification if you wish to use php in templates.

And you didnt follow that to the letter or else it would have worked just fine

Kirk Y 08-25-2006 12:13 AM

Just make a plugin using hook global_start. I do the same for header rotations on my forums. Don't know why people insist on working against vBulletin's templating system when it's easy enough to work with it... but that's just my daily rant. :)

Ian555 08-25-2006 12:18 AM

Obviously I am not setting up plugins properly.

I honestly cannot see what I missed
http://www.vbulletin.com/forum/showthread.php?t=170826

So please tell me what is the most simple and efficient way of making banners rotate working with the template system?

Thanks :)

Hook Location = ?
Title = ?
Execution Order = ?

Then how do you call it? Using the title?

I don't understand what a Plugin is... I guess it ain't an include then. :)

Kirk Y 08-25-2006 12:27 AM

Okay, let me see if I can explain it better:

Add a New Plugin using Hook Location "global_start".
Code:

$random_number = rand(1, 5);

$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>';

Remember to change all the Image Paths to the location of the banners you want to display.

Then edit whatever template you'd like to display the random banner in and stick this code wherever you'd like it to show:
Code:

$random_banner[$random_number]

Ian555 08-25-2006 12:33 AM

Ok thanks :)

The other thread I linked to says I need a different type of Hook location, and that doesn't work, so I guess I'll try it using the global_start instead.

Cheers

Kirk Y 08-25-2006 12:37 AM

Well global_start allows you to use it anywhere on the forum -- in my case, I use it on the Header for a Logo Rotation. It all depends on the template you're trying to put the banner in - the header template's only hook is global_start.

zooki 09-03-2006 10:48 PM

Hi, can i ask, how could i also get Google Adsense in there

$random_banner[3] = '<a href="http://www.link3.com/"><img src="path/to/banner3.gif" alt="" border="0" /></a>';

Could i do Random_banner[3] = ' adsense code here.... ' ??

Right now i have adsense ads on my page, but i had requests from people for adding some seperate banners..... was wondering good and effective way to rotate that all in one space........ i am so tired, i hope someone can help..

thank you

Kirk Y 09-04-2006 12:15 AM

Yep, you could do that too.

furst 09-04-2006 02:24 AM

Good stuff there, acidburn. That helped me a whole lot.

If I want to run 10 random banners, do I just replace rand(1, 5); with $random_number = rand(1, 10);?

Also, how could I create a few different plug-ins like this so that I can run different banners in different areas?

Kirk Y 09-04-2006 02:53 AM

Yep, just change the variable like you've got it there.

Using this plugin at hook location global_start enables the $random_banner variable to be used anywhere on the forum.

twobob 09-04-2006 10:36 AM

acidburn - thanks for the tip about using global_start as the hook location. When I followed the instructions from the .com post, the hook location that was automatically selected was ajax_start ... probably because that is the first of the hooks in the drop down menu.

global_start clearly works well for this MOD, but what other hook locations would also be appropriate to select?

Thanks again, twobob

Kirk Y 09-04-2006 09:23 PM

It all depends on what template you're trying to add the variable to.

For example, if you wanted to place the ads on your Forumhome (Index), you'd place the variable in the forumhome template and set the hook location to forumhome_start.

But like I said, using global_start let's you use it anywhere.

furst 09-05-2006 09:30 PM

Hey acidburn, pray tell, how can I do this:

$random_banner[1] = '<a href="http://www.link1.com/"><img src="path/to/banner1.gif" alt="" border="0" /></a>';

and have different images appear for random_banner[1]? For instance, I want to rotate /images/banners/banner[1-20].jpg but use the same link each time. Do I have to place them all in different $random_banner lines or is there a shortcut?

Kirk Y 09-05-2006 10:52 PM

In your case, it's simpler just to set them all on seperate lines.

zooki 09-06-2006 10:10 PM

Hi guys,


One Question is How do i get it to display on the VB CMPS?


you might wanna check this page out for future reference:
Rotating Banners in NavBar
https://vborg.vbsupport.ru/showthread.php?t=120707

Crazace2006 10-11-2006 01:35 PM

What would the Plugin Hook Location for the footer be?

Kirk Y 10-11-2006 08:45 PM

Just use global_start.

Tammy05 10-14-2006 04:15 AM

Does this work for the new vb 3.6?

Kirk Y 10-14-2006 05:51 PM

It will work on any version of vBulletin that supports the Plugin System. At the moment, anything 3.5.x and up.

Tammy05 10-14-2006 07:01 PM

Quote:

Originally Posted by acidburn0520
It will work on any version of vBulletin that supports the Plugin System. At the moment, anything 3.5.x and up.

thast odd because i did everyting correctly however the header area showed up empty.

Kirk Y 10-14-2006 07:23 PM

I'm using it on my 3.6.2 forum, so I can assure you that it works. Recheck all the steps and be sure you didn't miss something.

bada_bing 10-15-2006 01:54 AM

subscribes

Shazz 10-15-2006 02:00 AM

Thats the most easiest plugin and cleanest to install
If there was reputation stats I would add one to you acidburn0520
/me props*

Kirk Y 10-15-2006 02:07 AM

lol, thanks Shazz. Happy to help. :)

Criticize 02-07-2007 01:07 PM

My banners are not rotating, I have 5 that are currently setup but two of the same banners keep showing. Please help me.

www.club246.com is the site

Thank you!

Kirk Y 02-07-2007 04:15 PM

It's all random, each banner has a 1/5 chance of being displayed... assuming you've installed it right, you'll eventually see them all. Post up the Plugin code you're using just be sure, though.

double_d 01-06-2008 06:14 AM

Quote:

Originally Posted by Kirk Y (Post 1059879)
Okay, let me see if I can explain it better:

Add a New Plugin using Hook Location "global_start".
Code:

$random_number = rand(1, 5);

$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>';

Remember to change all the Image Paths to the location of the banners you want to display.

Then edit whatever template you'd like to display the random banner in and stick this code wherever you'd like it to show:
Code:

$random_banner[$random_number]

what does this mean
i would like this
do i have to write a php script and call it global_start ???
only new at this
please help me

daniel d

MoT3rror 01-06-2008 06:49 AM

Hook Location: global_start (Makes it available on anypage)
Title: Random Banner (You can make your own name)
Execution Order: 1
PHP Code:
Quote:

$random_number = rand(1, 5);

$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>';
Plugin is Active: Yes

Then you put
Quote:

$random_banner[$random_number]
in a template.

Kirk Y 01-06-2008 04:11 PM

AdminCP -> Products & Plugins -> Add New Plugin

buurman 01-08-2008 08:47 AM

Thanks Kirk, works great!! also made a rotating header logo.

happy I found your replys :)

kronnos 02-04-2008 01:28 PM

Quote:

Originally Posted by Kirk Y (Post 1059879)
Okay, let me see if I can explain it better:

Add a New Plugin using Hook Location "global_start".
Code:

$random_number = rand(1, 5);

$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>';

Remember to change all the Image Paths to the location of the banners you want to display.

Then edit whatever template you'd like to display the random banner in and stick this code wherever you'd like it to show:
Code:

$random_banner[$random_number]

What if I would want to have just 2 banner options but not show them randomly, instead if its forum home, then show one ad if its something else show another?

Kirk Y 02-04-2008 02:18 PM

Then you don't need to use this plugin.

Instead use template conditionals to output a header based on what page the user is viewing.

Example:
Code:

<if condition="THIS_SCRIPT == 'index">Show this only on the Index<else />Show this on pages other than the Index</if>
That's a very basic example, if you'd like some more information: http://www.vbulletin.com/docs/html/t...e_conditionals

kronnos 02-04-2008 05:51 PM

Quote:

Originally Posted by Kirk Y (Post 1436106)
Then you don't need to use this plugin.

Instead use template conditionals to output a header based on what page the user is viewing.

Example:
Code:

<if condition="THIS_SCRIPT == 'index">Show this only on the Index<else />Show this on pages other than the Index</if>
That's a very basic example, if you'd like some more information: http://www.vbulletin.com/docs/html/t...e_conditionals

Tried it but it still doesn't work. It just shows both in one ad block. Could it be that the ad block does not allow php code?

--------------- Added [DATE]1202145412[/DATE] at [TIME]1202145412[/TIME] ---------------

This is the code i tried but it shows the ad code and the text:

<if condition="THIS_SCRIPT == 'index'">

<center><script type="text/javascript"><!--
google_ad_client = "pub-8336492106717154";
//120x60, created 1/25/08
google_ad_slot = "4645103244";
google_ad_width = 120;
google_ad_height = 60;
google_cpa_choice = ""; // on file
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<center/>


<else />


This text


</if>

Ranger269 02-04-2008 07:37 PM

Quote:

Originally Posted by MoT3rror (Post 1416362)

Execution Order: 1

I was wondering about that. The default setting I had was "5" so I left it that way and the banner works fine.

I didn't understand just what that was for?

Should I change it to "1"?

Kirk Y 02-04-2008 09:45 PM

Quote:

Originally Posted by kronnos (Post 1436262)
Tried it but it still doesn't work. It just shows both in one ad block. Could it be that the ad block does not allow php code?

What template are you using this in; and on what version of vBulletin? I tested the code you supplied above and it worked perfectly for me.

Quote:

Originally Posted by Ranger269 (Post 1436336)
I was wondering about that. The default setting I had was "5" so I left it that way and the banner works fine.

I didn't understand just what that was for?

Should I change it to "1"?

Execution orders allow Plugins within a modification which utilize the same hook to be run in a specific order. ie. Plugin A gathers the UserID, Plugin B executes a query based on the userid, and Plugin C displays something based on the query. Thus Plugin A must be run before Plugin B and Plugin B must be run before Plugin C. This can be achieved by setting the Execution Orders of the three plugins to 1, 2, and 3 (respectively).

Ranger269 02-05-2008 01:41 AM

Quote:

Originally Posted by Kirk Y (Post 1436393)

Execution orders allow Plugins within a modification which utilize the same hook to be run in a specific order. ie. Plugin A gathers the UserID, Plugin B executes a query based on the userid, and Plugin C displays something based on the query. Thus Plugin A must be run before Plugin B and Plugin B must be run before Plugin C. This can be achieved by setting the Execution Orders of the three plugins to 1, 2, and 3 (respectively).

Thanks!

I'm having trouble with two rotating banners on the same forum...

https://vborg.vbsupport.ru/showthread.php?t=169672

I had both plugins set at 5 which was the default, so I changed them to 1 & 2.

But it still didn't fix the problem. :confused:

Kirk Y 02-05-2008 03:41 AM

Well execution orders wouldn't matter in that instance. I'm going to bet your problem is that you're not using different variable names for each banner.

ie: $random_banner and then $random_banner2

Ranger269 02-05-2008 04:13 AM

Quote:

Originally Posted by Kirk Y (Post 1436504)
Well execution orders wouldn't matter in that instance. I'm going to bet your problem is that you're not using different variable names for each banner.

ie: $random_banner and then $random_banner2

That's what I figured the problem was but I didn't know how to do it.

Code:

<div align="center">$random_banner[$random_number]</div>
When I tried adding a "2" between "number" and "]", it made the bottom banner disapear.

Can you tell me what code I need and if both of them need to be changed or only the bottom one?

kronnos 02-05-2008 06:06 AM

Quote:

Originally Posted by Kirk Y (Post 1436393)
What template are you using this in; and on what version of vBulletin? I tested the code you supplied above and it worked perfectly for me.

I'm Using Ultimate Side Columns and trying to paste this code into one of the left column blocks.


All times are GMT. The time now is 11:36 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01465 seconds
  • Memory Usage 1,839KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_code_printable
  • (12)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete