Advertisement:

Author Topic: How To Make Random Header Images  (Read 1721 times)

Offline mindazor

  • Newbie
  • *
  • Posts: 5
How To Make Random Header Images
« on: January 12, 2020, 06:27:24 AM »
hallo evry one I nead a Code How to make Random Header Background Images?

Like this one: hxxp:"http://zaxo.at/index.php?action=forum;theme=22" [nonactive]
« Last Edit: January 12, 2020, 06:40:54 AM by mindazor »

Offline Looking

  • SMF Hero
  • ******
  • Posts: 2,506
  • SMF Customization
    • jeanborde on Facebook
    • SMF Custom Themes & Custom Coding
Re: How To Make Random Header Images
« Reply #1 on: January 12, 2020, 09:45:31 AM »
There are many ways to do this but it is more than the code, you will need to implement it in theme properly but in any case you could use PHP to do a random pick between numbers and then put the class in relevant place like:

Code: [Select]
$random=rand(1,3);
$headercss="cssclass";
if($random==2){$headercss="cssclass2";}
if($random==3){$headercss="cssclass3";}

Offline Sir Osis of Liver

  • SMF Super Hero
  • *******
  • Posts: 10,665
  • We were all equal in the end.
Re: How To Make Random Header Images
« Reply #2 on: January 12, 2020, 11:11:51 PM »
Can also do it like this -

Code: [Select]

$pic = rand(1,5);

echo '
<img src="',$settings['images_url'],'/img/topr', $pic ,'.jpg" alt="" />';


Where images are topr1.jpg, topr2.jpg, etc.
“The best laid schemes o' mice an' men / Gang aft a-gley.” - Robert Burns