That's why in really long examples I close the line, and put the variable on it's own line something like ', $old_time, ' yesterday Because to me, all those <?php and ?> gives me a headache - ends up so much code you can't see the forest for the trees. But then I also force 70 column wraps and am a formatting nazi. TAB KEY - USE IT
That's a nice method, I may well give it a go sometime. As for the .tpl query - would it be possible to add the php code directly into the index.php file itself, wherever the header.tpl is referenced (in the index.php file) at the moment?
Well, this is not the default template and i couldnt find any referrers to any .tpl files in index.php Are there some non php ways to make ad rotation?
You could inline the whole thing as javascript. The code would be remarkably similar. Hang on, I'll toss together a port.
This should do the trick. <script type="text/javascript"> var banner_list=new Array( new Array('banner1.jpg','www.website1.com'), new Array('banner2.jpg','www.website2.com'), new Array('banner3.jpg','www.website3.com') ); var chosen_banner=Math.floor(banner_list.length*Math.random()); document.write('<a href="http://',banner_list[chosen_banner][1],'"><img src="http://www.yoursite.com/banners/',banner_list[chosen_banner][0],'" /></a>'); </script> Code (markup): The random number code is a bit tricky because javascripts random returns a floating point number 0..1
LOL IT WORKS! Thanks a lot mate, that really did help Also thanks a bunch for Cloudberries. Rep added to both of you.
Sorry to bring this topic back up. But I have edited deathshadow's javascript so that i displays a link like: <a href="...">...</a> etc. However, how can i then put it into a text box so that only <a href="...">...</a> shows up instead of the whole javascript.. ?
I assume you mean the TEXTAREA tag. Those can be one of the more annoying elements to work with because of it's habit of showing the code. Best bet? Write out the textarea in the script too... though I'm not sure why you'd want the anchor in a textarea.