Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 03-26-2009, 08:32 AM
valdet's Avatar
valdet valdet is offline
 
Join Date: Feb 2007
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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>';
and I use this code to call that function in my header template

$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++;}
Can you please show me in simple terms how would I go about displaying my banners in looped ordered manner like this:
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>';
I used this code in my header template

$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
Reply With Quote
  #2  
Old 04-02-2009, 11:38 AM
valdet's Avatar
valdet valdet is offline
 
Join Date: Feb 2007
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Bumping this thread. I hope for an advice..

Thanks.
Reply With Quote
  #3  
Old 04-03-2009, 11:42 AM
valdet's Avatar
valdet valdet is offline
 
Join Date: Feb 2007
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Are my threads too difficult that no one replies..

My other thread seems the same too.

Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:39 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04636 seconds
  • Memory Usage 2,186KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete