The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Different Branding every time

View previous topic View next topic Go down

In progress Different Branding every time

Post by J0k3R^ on June 26th 2014, 11:22 am

Hi, im using a branding on my forum but i want to make it change every time someone visits a new page in my forum.
If u check this: http://www.anime-greek.com/forums/index.phpu will understand what i mean.. (just click again n again at their logo)

J0k3R^
Forumember

Male Posts : 742
Reputation : 28
Language : Greek > English > Russian > Spanish
Location : C:\>r00t

http://fmplanet.forumgreek.com

Back to top Go down

In progress Re: Different Branding every time

Post by Ange Tuteur on June 26th 2014, 12:04 pm

Hello,

You can use JavaScript random math to pick a random banner to display.

Administration Panel > Modules > JavaScript codes management > Create a new script

Title : your choice
Placement : in all the pages
Paste the code below and save :
Code:
$(function() {
 var rand = Math.floor(Math.random() * 4);
 var logo = $('#logo img');
 
 if (rand === 0) logo.attr('src','/img.gif');
 if (rand === 1) logo.attr('src','/img.gif');
 if (rand === 2) logo.attr('src','/img.gif');
 if (rand === 3) logo.attr('src','/img.gif');
});

We set a range from 0 - 4, but not including 4. So, Math.floor(Math.random() * 4) will have a chance of 0, 1, 2, and 3. Increase the value of four and add more conditions to display a wider range of banners.

Also replace /img.gif by the URL of your image.

Ange Tuteur
Forumaster

Male Posts : 13021
Reputation : 2683
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum