The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
|
#1
|
||||
|
||||
Ordered display of banners
Hi there
In one site I currently have a simple banner rotating system, which enables different sponsors to have their banner shown. I was using this in a simple plugin on parse_templates hook Code:
$random_numbers = rand(1, 5); $banner[1] = '<a href=" http://www.somesite1.com"><img src="http://www.mysite.com/image1.jpg" alt="First message" border="0" /></a>'; $banner[2] = '<a href=" http://www.somesite2.com"><img src="http://www.mysite.com/image2.jpg" alt="Second message" border="0" /></a>'; $banner[3] = '<a href=" http://www.somesite3.com"><img src="http://www.mysite.com/image3.jpg" alt="Third message" border="0" /></a>'; $banner[4] = '<a href=" http://www.somesite4.com"><img src="http://www.mysite.com/image4.jpg" alt="Fourth message" border="0" /></a>'; $banner[5] = '<a href=" http://www.somesite5.com"><img src="http://www.mysite.com/image5.jpg" alt="Fifth message" border="0" /></a>'; $banner[$random_numbers] As you see the banners were displayed in completely random order. After some time, few sponsors are complaining that they see other banners more than they see theirs. Common complaints you know. Since my solution is simple and straightforward, I decided that I will make a slight change by displaying the banners in ordered/consecutive display, like 1 2 3 4 5 and not random like now 3 1 4 2 5 3 3 2 5 1 etc.... I did some research and came upon different resources for PHP codes to display them. Here are few: Code:
<?php $counter = 1; while ($counter <= 12) { echo $counter; $counter++; } ?> Code:
<?php function counter($y,$x) { $counter = $y; while ($counter <= $x) { echo $counter; $counter++; }} counter(1,9) ?> Code:
while ($i <= 5){ $banner[$i] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>'; $i++;} image1.jpg image2.jpg image3.jpg image4.jpg image5.jpg image1.jpg image2.jpg image3.jpg . . . . . . . . . Thanks and I look forward to your replies. --------------- Added [DATE]1238075409[/DATE] at [TIME]1238075409[/TIME] --------------- I found a tip elsewhere, but the banners are not displaying at all Code:
function counter($y,$x) { $counter = $y; while ($counter <= $x) { $counter++; }} $ordered_numbers = counter(1, 5); $banner[1] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>'; $banner[2] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>'; $banner[3] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>'; $banner[4] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>'; $banner[5] = '<a href=" http://www.somesite.com"><img src="http://www.mysite.com/image1.jpg" alt="Some message" border="0" /></a>'; $banner[$ordered_numbers] I tried the above as single plugin and came up with errors Then I declared function counter($y,$x) as separate plugin in global_start hook with the rest of the code in another plugin, but this thing is not showing up. I am sure something rather simple is missing from here. Can someone please take a quick look and let me know what needs to be done so banners are displayed in consecutive order. I know this may sound weird because when there are many users the display will still look to you as random, but at least each banner gets equal impressions. Thanks |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|