Is there a way to code the theme image at the top of my site,
http://mmdn.org/Testsite
to rotate everytime someone visits or refreshes the site? I have about 10 different images I'd like to rotate.
The banners function doesnt work well, it doesnt center it and has it in the upper left
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- internetking created topic »password problem« 25. May
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 25. May
- mazdev responded to »Pages 2.5.0 and updating - Page not found« 25. May
- ehdwma created topic »Hide "Register new account" and change template to 3 col« 25. May
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 25. May
- mdee created topic »How to implement returnpage ?« 25. May
- nestormateo responded to »Fillters in Clip« 24. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
Rotating theme image
-
- Rank: Expert
- Registered: Mar 15, 2003
- Last visit: Oct 21, 2009
- Posts: 1221
I use a small flash app for this when my clients request it.
You could also do it with a PHP script using the rand funtion (Don't have one handy)
--
Zikula Themes -
**unknown user**
- Rank: Expert
- Registered: Mar 16, 2002
- Last visit: Apr 02, 2010
- Posts: 1208
AGlossop
Maybe try editing the theme so that the banner image appears where you want it. Banners is probably the easiest way to do what you want. As far as I know anyway.
That is exactly what I did at http://www.landdevelopmenttoday.com. It works great. If you visit the site, it is the image at the top right side. The client occasionally changes the images to allow for quite a bit of variation.
Note: You might want to do some searching in the forums here. I seem to remember that someone wrote a plugin for Xanthia which would do this for you. I think it might have been InvalidResponse that did it... if IR did it, you can bet it's good stuff. :) -
**unknown user**
- Rank: Senior
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 2330
Insert this code above where the image is to be displayed in your theme.Code
<?php
// PUT EACH IMAGE INTO THE ARRAY AS SHOWN.
// FILENAMES DO NOT MATTER SO LONG AS THEY
// ARE VALID IMAGE NAMES
$head_imgs = array(1=> 'image_01.jpg',
'image_02.jpg',
'image_03.jpg',
'image_04.jpg',
'image_05.jpg');
// GET A RANDOM NUMBER (1 & 5 ARE INCLUSIVE...
// CHANGE THE "5" TO THE NUMBER OF IMAGES
// YOU'VE GOT IN THE ARRAY ABOVE
$sel_img = rand(1,5);
// HERE'S THE IMAGE TAG WITH THE RANDOM
// IMAGE INCLUDED. BE SURE TO CHANGE
// THE PATH TO YOUR IMAGES.
$use_img = '<img src="/your/img/path/'. $head_imgs[$sel_img] .'" alt="" / >';
// REMOVE THIS AFTER YOU VERIFY IT WORKS
echo $use_img;
?>
To use the random image in your theme, it would be:
Code
<img src="/your/img/path/<?php echo $head_imgs[$sel_img]; ?>" alt="" / >
Enjoy! -
**unknown user**
- Rank: Senior
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 2204
mt_rand() can be up to 4 times faster than rand() (depending on the system) .. also you could get a count if you didn't key the array.
$im = array('image.gif','image2.gif','image3.gif');
$rand = '';
echo $rand;
mmm..functions as an index.. delicious. ;) -
**unknown user**
- Rank: Senior
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 2330
I just wanted to mention about the 4 times faster...isn't it mere fractions of nanoseconds in this application?
I didn't try it, but that's a sweet snip IR...nice... I just might have to change my approach...or at least add that technique to the ranks... Good stuff! :) I've worked on a few projects where that would be considered written a bit to "tightly" - read: too much happening in one line - but I like I like...
:) -
**unknown user**
- Rank: Senior
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 2204
alarconcepts
I just wanted to mention about the 4 times faster...isn't it mere fractions of nanoseconds in this application?
haha.. well, I don't know anyone who would "knowingly" use the slower of 2 anything. you're right though, definitely.. it's just a matter of "best practices".
alarconcepts
I didn't try it, but that's a sweet snip IR...nice... I just might have to change my approach...or at least add that technique to the ranks... Good stuff! :) I've worked on a few projects where that would be considered written a bit to "tightly" - read: too much happening in one line - but I like I like...
good, good.. hope it comes in handy. :)
see ya! -
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 26
ok, im not the brightest, how do i make it centered and looking flush with the bottom graphic. Currently it looks like http://mmdn.org/Testsite
And the image only loads up sometimes, (keep hitting refresh) -
**unknown user**
- Rank: Softmore
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 151
The size of the image I see is a 1000px wide try scaling it to a more appropriate size for the size. What is the width of your theme?
It didn't load for me the first time either.
You can see how I did it on my site here
- Moderated by:
- Support
