MyBB Community Forums

Full Version: How To Display Random Ads
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
my problem about "My Advertisement"
http://mods.mybb.com/view/my-advertisements
Angel

how to create an ad code if my ad more than one that I want to display on the header, so that advertising has always run "RANDOM" every time user or guest "Reload/Replenish (Browsing)" the ads that will appear will be different from before.

if anyone should be added? or make a separate code in zone ad?
please let me know if there is someone can solve my problem. Big Grin

I hope my friends here know what I mean Wink

thanks in advance Blush
Google AdSense runs random targeted ads... as far as randomizing a set of predefined advertisement scripts (considering most ads are javascript based for tracking purposes) you'll have to modify the plugin or write your own script to rotate your own adv blocks. You can Google "banner rotation script"s and use those code snippets to your liking.
yes, I know that the google ads on the display randomly namum what if we put ads in the "header" of more than one?
for example, we have an ad from google and amazon well if the user or guest visiting our forum ads will appear, and if the user or guest is our forum then reload the ads that will appear different. Big Grin
You mean,

-> I visit your forum I see GOOGLE ADS
-> I refresh, AMAZON Ad comes INSTEAD of Google

right?

If yes, let me right a code Big Grin
yeah right ...

thus, the location of the ads on the header there are 3 ads (eg), and every time a guest or member reload my forum it will show a different ad.

something like that.
Cool, good luck! Basically just random picking a selection from an array. Because of Google terms of use you'll probably need to do PHP because html/js way would load all ads at once and then hide all but one. Good luck on the plugin for this Cedric!
Use Template Conditionals. On mybbhacks site there is explained how to use mt_rand in it.
(2013-03-27, 12:36 AM)Destroy666 Wrote: [ -> ]Use Template Conditionals. On mybbhacks site there is explained how to use mt_rand in it.

Can I ask for URLs of mybbhacks
I think this might be what you're looking for:
http://mybbhacks.zingaburga.com/showthread.php?tid=260

if so click the link in my sig ;D
This is easy to do, put this code in index.php [Only main site page] , or global.php [Display everywhere!]

// Considering the ADcodes as an array!
$ads = array(
"1st AD Code Here. Note: Remember about Escape Sequences or PHP will pull out error!",
"2nd AD Code Here. Note: Remember about Escape Sequences or PHP will pull out error!",
"3rd AD Code Here. Note: Remember about Escape Sequences or PHP will pull out error!",
);

$randomadcodes = $ads[rand(0, count($quotes) - 1)];

Then go to your header template & put {$randomcodes} to display them Big Grin

Enjoy!
Pages: 1 2