Calendar


Upcoming Events (Within next 31 days):
just a little test (on Fri 30th Jul at 19:00)
just a little test (on Fri 6th Aug at 19:00)
just a little test (on Fri 13th Aug at 19:00)

Upcoming Birthdays (Within next 31 days):
Congratulations to: Jayge (? on Fri 27th Aug)
JKThinking (28 on Wed 11th Aug)
Donations

All information and modifications on this site are open source and free, but any donations are gratefully received. They also provide the fuel (beer) that keeps me motivated!

Thanks, Stu

Online Users

In total there are 0 users online :: 0 registered, 0 hidden and 0 guests.

Most users ever online was 208 on Mon Jul 12, 2010 8:05 am

Users browsing this forum: No registered users and 0 guests based on users active over the past 60 minutes

Random Banner MOD

A collection of small, simple hacks

Moderators: Dev Team, SGP Team, MODerators

Random Banner MOD

PostAuthor: livewirestu on Sat Sep 06, 2008 7:24 pm

This mod displays a randomly selected banner for your site header. You can see this mod in action on this site if you refresh your page a couple of times (note that it does not work perfectly as I don't have many images - so the random number generator has a pretty good chance of generating the same number on each refresh)
This is such a small hack that it barely warrants a full modx package (also, some parts need to be adjusted as per preference).
Some parts of the php file are borrowed from Michaelo's sgp_get_rand_logo() function from SGP (in includes/sgp_functions.php).
So far, I have only written this mod for prosilver.

Here goes...
Create a new folder called 'banners' in styles/your_prosilver_based_style/theme/images and place any banner images you want in here.
Bear in mind that images will not be resized and so may stretch your site sideways if they are too large. What I have done for my banner images is make them all 750x170 pixels. Then at the right edge of each image, I have faded them out to black. Then I made the background colour of the header black too. The images now merge into the background colour seamlessly and as you stretch your browser out there is no distortion. If you reduce your browser window below 750 pixels wide, you will just get a scroll bar.

Copy this file into styles/your_prosilver_based_style/theme/images
(yes - we are putting a php file in the images directory :P)
random_banner.zip
styles/prosilver/theme/images
(723 Bytes) Downloaded 150 times


Open styles/your_prosilver_based_style/theme/colours.css
Find:
Code: Select all
.headerbar {
   background-color: #12A3EB;
   background-image: url("{T_THEME_PATH}/images/bg_header.gif");
   color: #FFFFFF;
}

Replace with:
Code: Select all
.headerbar {
   background: url("{T_THEME_PATH}/images/random_banner.php") no-repeat;
   color: #FFFFFF;
    background-color: #000000;
}

You can now use your artistic preference to alter the colours in this edit. Change 'color' to alter the colour of your site description text. Change background-color to alter the... erm... background colour.

Open styles/your_prosilver_based_style/theme/common.css
Find:
Code: Select all
/* Site description and logo */
#site-description {
   float: left;
   width: 70%;
}

Replace with:
Code: Select all
/* Site description and logo */
#site-description {
   float: left;
   width: 70%;
   height: 160px;
}

#site-description a {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}


Now change the height so that it is 10 pixels less than the height of your banner images (the 10 pixels is to account for the rounded corners at the top and bottom of panel).

Refresh all your caches and you are done ;)
Enjoy.
This mod works nicely in conjunction with my 'Header tidy up' mod, details of which will be posted soon (although you can see the effects of it on this site)
Cheers,
Stu
User avatar
livewirestu
Site Admin
 
Posts: 582
Joined: Thu Jul 31, 2008 6:18 pm
Location: Hastings, England

Re: Random Banner MOD

PostAuthor: TenEightyOne on Wed Sep 17, 2008 4:47 pm

I've just installed this on [url=http://www.worldleagueracing.com/forum] and it works really well!!!

Just one question; I currently have three gifs (sitelogo1, sitelogo2 and sitelogo3). #1 seems to be chosen five times more than 2 while 3 is rarely chosen at all.

Is there something I can do to average the chances of each logo being chosen... if that makes sense?
TenEightyOne
 
Posts: 13
Joined: Fri Sep 12, 2008 12:22 pm

Re: Random Banner MOD

PostAuthor: livewirestu on Wed Sep 17, 2008 5:11 pm

Yeah the random number generator leaves a lot to be desired! It doesn't work too great with small numbers.
I'll have a look to see if I can improve it somehow.
User avatar
livewirestu
Site Admin
 
Posts: 582
Joined: Thu Jul 31, 2008 6:18 pm
Location: Hastings, England

Re: Random Banner MOD

PostAuthor: livewirestu on Wed Sep 17, 2008 5:27 pm

You could try removing the seed for the random number generator. It's quite hard to quantify if this works well with such small numbers involved. If you are choosing a random number between 1-3, chances are it will pick the same number twice or more in a row quite frequently.
Anyway, try this...
in styles/prosilver/theme/images/random_banner.php
Find:
Code: Select all
mt_srand((double)microtime()*1000001);

Replace with:
Code: Select all
//mt_srand((double)microtime()*1000001);


Let me know how that works out for you.
User avatar
livewirestu
Site Admin
 
Posts: 582
Joined: Thu Jul 31, 2008 6:18 pm
Location: Hastings, England

Re: Random Banner MOD

PostAuthor: TenEightyOne on Wed Sep 17, 2008 7:37 pm

A little better.

I'm going to make another seven or eight banners tonight to put in the banners folder so I'll see how it goes after that.

Thank you :D
TenEightyOne
 
Posts: 13
Joined: Fri Sep 12, 2008 12:22 pm

Re: Random Banner MOD

PostAuthor: n66x on Mon Feb 15, 2010 1:50 am

this looks like a very interesting mod I want to install this but the instructions don't help cause i have the 'xandgrey' style installed..
do you think i can install this there or should i look for a mod especially made for that style?

thank you in advance,
n66x
 
Posts: 1
Joined: Mon Feb 15, 2010 1:39 am

Re: Random Banner MOD

PostAuthor: HelterSkelter on Thu Mar 04, 2010 11:07 pm

this will work with any theme
HelterSkelter
Site Admin
 
Posts: 1
Joined: Fri Aug 08, 2008 2:33 am


Return to Small mods and quick hacks

Who is online

Users browsing this forum: No registered users and 1 guest

cron