Mediajuggle Posted August 23, 2005 Posted August 23, 2005 okay you guys helped me with my first problem. I wanted to add a redirect to the content management system that I was using so that it would display a certain page if the language being used was english and another if the language being used was spanish... so we came up with: <?PHP if ($languages_id == '1') { $number = "1"; $category="5"; $template = "pages"; include("../admin/show_news.php"); } else { $number = "1"; $category="6"; $template = "pages"; include("../admin/show_news.php"); } ?> and it's work perfectly... but now i'd like to add a javascript.... <script language="JavaScript"><!-- function adArray() { for (i=0; i*2<adArray.arguments.length; i++) { ?this[i] = new Object(); ?this[i].src = adArray.arguments[i*2]; ?this[i].href = adArray.arguments[i*2+1]; } this.length = i; } function getAdNum() { dat = new Date(); dat = (dat.getTime()+"").charAt(8); if (dat.length == 1) ?ad_num = dat%ads.length; else ?ad_num = 0; return ad_num; } var ads = new adArray( "http://www.musica360.com/images/musica360_04.gif","http://musica360.com/store/login.php", "http://www.musica360.com/images/musica-musica.jpg","http://musica360.com/store/features.php", "http://www.musica360.com/images/musica-affiliate.jpg","http://musica360.com/store/affiliate_info.php", "http://www.musica360.com/images/subscription.jpg","http://musica360.com/store/vip.php"); var ad_num = getAdNum(); // document.write('<A HREF="'+ads[ad_num].href+'" ><IMG SRC="'+ads[ad_num].src+'" ' +' BORDER=0 name=js_ad alt=""></A>'); link_num = document.links.length-1; function rotateSponsor() { if (document.images) { ?ad_num = (ad_num+1)%ads.length; ?document.js_ad.src = ads[ad_num].src; ?document.links[link_num].href = ads[ad_num].href; ?setTimeout("rotateSponsor()",30000); } } setTimeout("rotateSponsor()",30000); // --></script> so that if it's on an english page... the english images are rotated if the site is set for english and another rotate another set if it was in spanish.... i tried... <?PHP if ($languages_id == '1') { <script language="JavaScript"><!-- function adArray() { for (i=0; i*2<adArray.arguments.length; i++) { ?this[i] = new Object(); ?this[i].src = adArray.arguments[i*2]; ?this[i].href = adArray.arguments[i*2+1]; } this.length = i; } function getAdNum() { dat = new Date(); dat = (dat.getTime()+"").charAt(8); if (dat.length == 1) ?ad_num = dat%ads.length; else ?ad_num = 0; return ad_num; } var ads = new adArray( "http://www.musica360.com/images/musica360_04.gif","http://musica360.com/store/login.php", "http://www.musica360.com/images/musica-musica.jpg","http://musica360.com/store/features.php", "http://www.musica360.com/images/musica-affiliate.jpg","http://musica360.com/store/affiliate_info.php", "http://www.musica360.com/images/subscription.jpg","http://musica360.com/store/vip.php"); var ad_num = getAdNum(); // document.write('<A HREF="'+ads[ad_num].href+'" ><IMG SRC="'+ads[ad_num].src+'" ' +' BORDER=0 name=js_ad alt=""></A>'); link_num = document.links.length-1; function rotateSponsor() { if (document.images) { ?ad_num = (ad_num+1)%ads.length; ?document.js_ad.src = ads[ad_num].src; ?document.links[link_num].href = ads[ad_num].href; ?setTimeout("rotateSponsor()",30000); } } setTimeout("rotateSponsor()",30000); // --></script> } else { <script language="JavaScript"><!-- function adArray() { for (i=0; i*2<adArray.arguments.length; i++) { ?this[i] = new Object(); ?this[i].src = adArray.arguments[i*2]; ?this[i].href = adArray.arguments[i*2+1]; } this.length = i; } function getAdNum() { dat = new Date(); dat = (dat.getTime()+"").charAt(8); if (dat.length == 1) ?ad_num = dat%ads.length; else ?ad_num = 0; return ad_num; } var ads = new adArray( "http://www.musica360.com/images/musica360_04-sp.gif","http://musica360.com/store/login.php", "http://www.musica360.com/images/musica-musica-sp.jpg","http://musica360.com/store/features.php", "http://www.musica360.com/images/musica-affiliate-sp.jpg","http://musica360.com/store/affiliate_info.php", "http://www.musica360.com/images/subscription-sp.jpg","http://musica360.com/store/vip.php"); var ad_num = getAdNum(); // document.write('<A HREF="'+ads[ad_num].href+'" ><IMG SRC="'+ads[ad_num].src+'" ' +' BORDER=0 name=js_ad alt=""></A>'); link_num = document.links.length-1; function rotateSponsor() { if (document.images) { ?ad_num = (ad_num+1)%ads.length; ?document.js_ad.src = ads[ad_num].src; ?document.links[link_num].href = ads[ad_num].href; ?setTimeout("rotateSponsor()",30000); } } setTimeout("rotateSponsor()",30000); // --></script> } ?> but needless to say that didn't work.... Can anyone give me a hand with the syntax? My Contribution Music Download Store Template http://www.oscommerce.com/community/contributions,4275
gscreations Posted August 23, 2005 Posted August 23, 2005 ok not sure if this will work but in your code: <?PHP if ($languages_id == '1') { $number = "1"; $category="5"; $template = "pages"; include("../admin/show_news.php"); } else { $number = "1"; $category="6"; $template = "pages"; include("../admin/show_news.php"); } ?> why not just use includes to link to external javascript, so you save the english javascript in a file lets call it : includes/english_script.js and the spanish as includes/spanish_script.js then add change the above code to: <?PHP if ($languages_id == '1') { $number = "1"; $category="5"; $template = "pages"; include("../admin/show_news.php"); include("includes/english_script.js"); } else { $number = "1"; $category="6"; $template = "pages"; include("../admin/show_news.php"); include("includes/spanish_script.js"); } ?> should work i think
Mediajuggle Posted August 23, 2005 Author Posted August 23, 2005 but even when i try to do it with an image.... i get an error... my last attempt was... <?PHP if ($languages_id == '1') { <a href="http://www.musica360.com/store/bestselling_products.php" border="0"><img src="http://www.musica360.com/store/images/center-image.jpg">); } else { <a href="http://www.musica360.com/store/bestselling_products.php" border="0"><img src="http://www.musica360.com/store/images/center-image-sp.jpg">); } ?> any ideas My Contribution Music Download Store Template http://www.oscommerce.com/community/contributions,4275
Mediajuggle Posted August 23, 2005 Author Posted August 23, 2005 thank you... i modified it to be <?PHP if ($languages_id == '1') { include("includes/english_script.js"); } else { include("includes/spanish_script.js"); } ?> and did the same for the single images..... thanks again for the help.... My Contribution Music Download Store Template http://www.oscommerce.com/community/contributions,4275
Recommended Posts
Archived
This topic is now archived and is closed to further replies.