Guest Posted September 15, 2008 Share Posted September 15, 2008 At the top of my homepage, I have a banner. Every now and again I need to edit my public_html/includes/modules/new_products.php file, and change the name of the jpg it is pointing to. The section of code I change is as follows; <IFRAME marginWidth=0 marginHeight=0 src="/images/rideons.jpg" frameBorder=0 width=516 scrolling=no height=172 allowTransparency> </IFRAME> In the above example the banner is called rideons.jpg Does anyone know a way that instead of calling ONE jpg file, I could have it randomly display from a group of banners? So that I could have 5 banenrs on the site called banner1.jpg, banner2.jpg etc and it loads one of them at random? This would obviously help my site look like it is updated more often, and mean I dont need to edit new_products.php any more. Many thanks if anyone is able to help Link to comment Share on other sites More sharing options...
germ Posted September 15, 2008 Share Posted September 15, 2008 MAKE A BACKUP BEFORE YOU BEGIN. Then replace the code you posted with this code: <?php /* coded for 5 images */ $br = rand(0,4); switch ( $br ) { case 0: $random_image ='banner1.jpg'; break; case 1: $random_image ='banner2.jpg'; break; case 2: $random_image ='banner3.jpg'; break; case 3: $random_image ='banner4.jpg'; break; case 4: $random_image ='banner5.jpg'; break; } ?> <IFRAME marginWidth=0 marginHeight=0 src="/images/<?php echo $random_image; ?>" frameBorder=0 width=516 scrolling=no height=172 allowTransparency> </IFRAME> (I'm not "clever". I just did something very similar to this in another thread recently) If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you. "Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice." - Me - "Headers already sent" - The definitive help "Cannot redeclare ..." - How to find/fix it SSL Implementation Help Like this post? "Like" it again over there > Link to comment Share on other sites More sharing options...
♥geoffreywalton Posted September 15, 2008 Share Posted September 15, 2008 Doesn't the stock banner manager take a random banner from the group you specify and display it? Then you can see banner display stats, control start end dates, control no of impressions to display etc. Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile Virus Threat Scanner My Contributions Basic install answers. Click here for Contributions / Add Ons. UK your site. Site Move. Basic design info. For links mentioned in old answers that are no longer here follow this link Useful Threads. If this post was useful, click the Like This button over there ======>>>>>. Link to comment Share on other sites More sharing options...
cg180659 Posted September 15, 2008 Share Posted September 15, 2008 At the top of my homepage, I have a banner. Every now and again I need to edit my public_html/includes/modules/new_products.php file, and change the name of the jpg it is pointing to. The section of code I change is as follows; <IFRAME marginWidth=0 marginHeight=0 src="/images/rideons.jpg" frameBorder=0 width=516 scrolling=no height=172 allowTransparency> </IFRAME> In the above example the banner is called rideons.jpg Does anyone know a way that instead of calling ONE jpg file, I could have it randomly display from a group of banners? So that I could have 5 banenrs on the site called banner1.jpg, banner2.jpg etc and it loads one of them at random? This would obviously help my site look like it is updated more often, and mean I dont need to edit new_products.php any more. Many thanks if anyone is able to help There is a pretty good contribution on that. Search random header image @ addons.oscommerce.com I've used it, and it works like this: everytime the page refreshes, it changes the header. So for example, if a customer came to your site they would see header 1, but then if they went to see a prodcut, and then come back to the index page (or whatever page ur using to place the banner) it would show a different banner image SPACE FOR RENT! Link to comment Share on other sites More sharing options...
Guest Posted September 15, 2008 Share Posted September 15, 2008 There is a pretty good contribution on that. Search random header image @ addons.oscommerce.com I've used it, and it works like this: everytime the page refreshes, it changes the header. So for example, if a customer came to your site they would see header 1, but then if they went to see a prodcut, and then come back to the index page (or whatever page ur using to place the banner) it would show a different banner image Sorted, many thanks for the superb help in this thread!! Link to comment Share on other sites More sharing options...
cg180659 Posted September 15, 2008 Share Posted September 15, 2008 There is a pretty good contribution on that. Search random header image @ addons.oscommerce.com I've used it, and it works like this: everytime the page refreshes, it changes the header. So for example, if a customer came to your site they would see header 1, but then if they went to see a prodcut, and then come back to the index page (or whatever page ur using to place the banner) it would show a different banner image Ok I think this is the link for that contribution http://www.oscommerce.com/community/contributions,1934 SPACE FOR RENT! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.