1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to make rotating banner

Discussion in 'HTML & Website Design' started by Leriss, Jul 5, 2007.

  1. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #21
    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 ;)
     
    deathshadow, Jul 5, 2007 IP
  2. Cloudberries

    Cloudberries Peon

    Messages:
    74
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #22
    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?
     
    Cloudberries, Jul 5, 2007 IP
    Leriss likes this.
  3. Leriss

    Leriss Well-Known Member

    Messages:
    506
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    130
    #23
    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?
     
    Leriss, Jul 5, 2007 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #24
    You could inline the whole thing as javascript. The code would be remarkably similar.

    Hang on, I'll toss together a port.
     
    deathshadow, Jul 5, 2007 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #25
    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
     
    deathshadow, Jul 5, 2007 IP
    Leriss likes this.
  6. Leriss

    Leriss Well-Known Member

    Messages:
    506
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    130
    #26
    LOL IT WORKS!

    Thanks a lot mate, that really did help :)
    Also thanks a bunch for Cloudberries.

    Rep added to both of you.
     
    Leriss, Jul 5, 2007 IP
  7. skidpics

    skidpics Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #27

    try using <php></php> tags instead of <?php?>
     
    skidpics, Aug 19, 2009 IP
  8. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #28
    Wow, necromancy on a 13 month old thread... and complete nonsensical gibberish at that!
     
    deathshadow, Aug 19, 2009 IP
  9. WebEvader

    WebEvader Well-Known Member

    Messages:
    1,026
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    115
    #29
    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.. ?
     
    WebEvader, Dec 31, 2009 IP
  10. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #30
    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.
     
    deathshadow, Dec 31, 2009 IP
    cgoly01 likes this.