• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

Rotate Ad Banners Based Upon Clock Seconds

Admin

Well-Known Member
Staff member
Administrator
One feature sorely missing from vBulletin 4 is the ability to "rotate" ad banners.


I have found other mods that allow you to do this, but they were overly complicated and cumbersome for what I needed.


This is a little hack that allows you to convert the mostly-useless "Display ad when PM storage is between X and X percent" into a rotating ad banner system.


After this mod is implemented, you will be able to specify the time on the clock secondhand when a specific banner is displayed. For example, if you had two banners, you could rotate them equally by displaying one between 0 and 29 seconds, and the other between 30 and 59 seconds.


This requires one code change and one phrase change.


For the code change, go to the includes directory and find functions_ad.php.


Search for:
Code:
                        case "pm_storage_x_percent_full":


Directly BELOW it, delete the following two lines:
Code:
                                                $conditional_prefix .= '<vb:if condition="$' . 'pmboxpercentage = $' . 'bbuserinfo[\'pmtotal\'] / $' . 'bbuserinfo[\'permissions\'][\'pmquota\'] * 100"></vb:if>';
                                                $conditional_prefix .= '<vb:if condition="$' . 'pmboxpercentage > ' . intval($criteria['condition1']) . ' AND $' . 'pmboxpercentage < ' . intval($criteria['condition2']) . '">';




In their place, put the following two lines:
Code:
                                                $conditional_prefix .= '<vb:if condition="$now = (mktime() % 60)"></vb:if>';
                                                $conditional_prefix .= '<vb:if condition="$now >= ' . intval($criteria['condition1']) . ' AND $now <= ' . intval($criteria['condition2']) . '">';




So the block should now look like:
Code:
                        case "pm_storage_x_percent_full":
                                                $conditional_prefix .= '<vb:if condition="$now = (mktime() % 60)"></vb:if>';
                                                $conditional_prefix .= '<vb:if condition="$now >= ' . intval($criteria['condition1']) . ' AND $now <= ' . intval($criteria['condition2']) . '">';
                                                $conditional_postfix .= "</vb:if>";
                                                break;




Now, just for aesthetics, go to Search in Phrases in the Admin Control Panel. Enter pm_storage_x_percent_full_criteria in the Search for Text box. Then click Phrase Variable Name Only under Search in. Then press the Find button.


It should find pm_storage_x_percent_full_criteria. Click the Edit button.


On the edit screen, enter the following in the "Translation" text box:


Code:
Display ad between {1} and {2} seconds


Then press Save and you are all done!




Now you will have a choice to select the seconds on the clock when certain ads are displayed. You set this on the Edit Ad screen. You can rotate up to 60 ads this way. You can even designate certain ads to come up more often than others, by giving some more time than others. For example, if you have Ad #1 display between 0 and 49 seconds, and Ad #2 display between 50 and 59 seconds, Ad #1 will display on average 5 times more often as Ad #2.


I have attached a screen shot of the Edit Ad screen. Notice that I checked the box labeled "Display ad between ____ and ____ seconds". You need to do that in order to enable this modification on any ad you display.
 

Facebook Comments

Similar threads

New posts New threads New resources

Back
Top