PDA

View Full Version : Ajax Rotating Includes Script



meakip
04-26-2008, 10:54 AM
1) Ajax Rotating Includes Script

2) http://www.dynamicdrive.com/dynamicindex17/ajaxrotate.htm:

3) Describe problem:

Hi, I have created an HTML test page and 7 includes files as directed and that works fine on random but when I added the code to header.php and the then the call code to my mainpage.php page nothing appears, I have also tried it by placing both Scripts in the mainpage.php but still nothing is the something extra I should do to make this work on a PHP page ?

here is my test php page http://www.pinkspiderdirect.com/slow/index.php

any help is appreiated.

Patrick

meakip
04-27-2008, 02:19 PM
Hi, Im still not able to get this to work, what I have done is strip out pretty much all but essential other javascript but it still doesnt display, what i have done codewise is below

header

<code>
<?php
// WebMakers.com Added: Down for Maintenance
// Hide header if not to show
if (DOWN_FOR_MAINTENANCE_HEADER_OFF =='false') {
?>
<link rel="stylesheet" type="text/css" href="<?php echo TEMPLATE_STYLE;?>">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<script type="text/javascript">

/***********************************************
* Ajax Rotating Includes script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

//To include a page, invoke ajaxinclude(files_array, "ROTATETYPE") in the BODY of page.
//* file_array is the name of the array containing your list of files to include.
//* For "ROTATETYPE", valid values are "dailyw", "dailym", and "random", for each day of the week, each day of the month, and random, respectively.
//* Included file MUST be from the same domain as the page displaying it.

//Enter path to list of files to display.
//For rotatetype="dailyw", there must be 7 files, and for "dailym", 31 files. Otherwise, no restriction:

var includefiles=["ajaxfiles/file.htm", "ajaxfiles/file2.htm", "ajaxfiles/file3.htm", "ajaxfiles/file4.htm", "ajaxfiles/file5.htm", "ajaxfiles/file6.htm", "ajaxfiles/file7.htm"]

var rootdomain="http://www.pinkspiderdirect.com"+window.location.hostname

function ajaxinclude(files_array, rotatetype){
includefiles=files_array
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
var url=choosefile(files_array, rotatetype)
if (typeof files_array[url]=="undefined"){
document.write("Error: No file for this day has been found.")
return
}
else
url=files_array[url]
page_request.open('GET', url, false) //get page synchronously
page_request.send(null)
writecontent(page_request)
}

function writecontent(page_request){
if (window.location.href.indexOf("http")==-1 || page_request.status==200)
document.write(page_request.responseText)
}

function choosefile(files_array, rotatetype){
var today=new Date()
var selectedfile=(rotatetype=="dailyw")? today.getDay() : rotatetype=="dailym"? today.getDate() : Math.floor(Math.random()*files_array.length)
if (rotatetype=="dailyw" && selectedfile==0) //if display type=="week days" and today is Sunday
selectedfile=7
if (rotatetype=="dailyw" || rotatetype=="dailym")
selectedfile-- //remove 1 to sync with array index
return selectedfile
}

</script>

</tr>
<table width="100%" height="84" border="0" cellpadding="0" cellspacing="0">
<td height="46" align="center" valign="baseline" nowrap background="http://www.pinkspiderdirect.com/sexshop/templates/Pixame_v1/images/NOTICEBG_GRADIENT.gif">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="10%" height="10" align="center" valign="middle"><font color="#FF0000" size="3"><strong>BookMark</strong></font><font color="#999999">-</font><font size="5" face="Webdings"><a style="text-decoration: none" title="Bookmark PINKSPIDERDIRECT.COM" href="javascript:bookmarksite('PinkSpiderDirect%20=%20Health%20Products',%20'http://www.pinkspiderdirect.com')">n</a></font></td>
<td width="67%" valign="middle"><div align="center"><font color="#C0C0C0"><a title="HOME" href="http://www.pinkspiderdirect.com/sexshop/information.php?info_id=2" style="text-decoration: none"><font color="#FF0000" size="1"><strong>UK
SHIPPING</strong></font></a></font><font color="#FF0000" size="1"><strong><font color="#000000" size="3">
-</font> </strong><font color="#C0C0C0"><a title="HOME" href="http://www.pinkspiderdirect.com/sexshop/information.php?info_id=8" style="text-decoration: none"><font color="#FF0000" size="1"><strong>OUTSIDE
THE UK </strong></font></a></font><strong> <font color="#000000" size="3">
- </font><font color="#FF0000" size="1"><font color="#C0C0C0"><a title="HOME" href="http://www.pinkspiderdirect.com/sexshop/information.php?info_id=12" style="text-decoration: none"><font color="#FF0000" size="1"><strong>CLOTHING
SIZES</strong></font></a></font></font></strong><font color="#FF0000" size="1"><font color="#C0C0C0"><font color="#000000"><strong>
</strong></font><font color="#FF0000" size="1"><strong><font color="#000000" size="3">-</font></strong></font><font color="#000000">
</font><font color="#FF0000" size="1"><strong><font color="#FF0000" size="1"><font color="#C0C0C0"><a title="HOME" href="http://www.pinkspiderdirect.com/sexshop/information.php?info_id=9" style="text-decoration: none"><font color="#FF0000" size="1"><strong>PAYMENT
METHODS </strong></font></a><font color="#FF0000" size="1"><font color="#FF0000" size="1"><font color="#FF0000" size="1"><strong><font color="#000000" size="3">-</font></strong></font></font></font><font color="#FF0000">
</font><font color="#C0C0C0"><a title="HOME" href="http://www.pinkspiderdirect.com/resource/publish/index.shtml" style="text-decoration: none"><font color="#0000FF" size="1"><strong>SHOPPING
GUIDES</strong></font></a></font><font color="#FF0000"> </font></font></font></strong></font></font></font></font></div></td>
<td width="16%" valign="middle"><img border="0" src="../../../shop/templates/Pixame_v1/images/buttons/pink_logo.gif" width="187" height="35"></td>
<td width="7%" valign="middle"><a><a title="WORLDWIDE DELIVERY" href="http://www.pinkspiderdirect.com/sexshop/information.php?info_id=2"><img src="../../../sexshop/templates/Pixame_v1/images/ukworld.gif" width="80" height="35" border="0"></a></a></td>
</tr>
<tr>
<td height="10" colspan="4" valign="bottom" background="http://www.pinkspiderdirect.com/sexshop/templates/Pixame_v1/images/menur_bg.gif">
<div align="center">
<link rel="stylesheet" type="text/css" href="<?php echo TEMPLATE_STYLE;?>">
</div></td>
</tr>
</table></tr>
<tr bgcolor="#FF0000">
<td height="19" bgcolor="#CC0000"> <table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="964" height="119" align="right" valign="top"> <div align="left"><div class="roundedcornr_box_930546">
<div class="roundedcornr_top_930546"> </div>
<div align="left" class="roundedcornr_content_930546"> </div>
<div class="roundedcornr_bottom_930546">
</td>
<td width="163" valign="middle"> <div align="center"> <img src="../../../sexshop/templates/Pixame_v1/images/beet.gif" width="100" height="78">
</div></td>
<td width="73" align="right" valign="middle"><div align="center">
<table width="65" height="119" align="right" cellpadding="5">
<tr>
<td width="62" height="106" align="center" valign="middle"><font color="#FFFFFF" size="4"><strong><?php echo '<a class="ShowCartDetails" href="' . tep_href_link(FILENAME_SHOPPING_CART) . '">' . tep_image(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/images/kart1.gif') . '</a>&nbsp;&nbsp;<br>
' . $cart->count_contents() . ($cart->count_contents() == "1" ? " Item" : " Items "); ?><br>
<?php echo $currencies->format($cart->show_total()); ?></strong></font></td>
</tr>
</table>
</div></td>
<td width="14" align="right" valign="middle">&nbsp;</td>
<td width="49" valign="middle"><b><font color="#66CCFF" size="4">
<?php } ?>
</font></b> <table width="38" cellspacing="0" cellpadding="0">
<tr>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr bgcolor="#FF0000">
<td height="19" bgcolor="#CC0000"><strong><?php echo $breadcrumb->trail(' &raquo; '); ?><b></b></strong></td>
</tr>
</table>
<code>

test page

http://www.pinkspiderdirect.com/slow/index.php

Hopefully this will make things clearer to someone.

Many thanks for any help in advance

Patrick

meakip
04-27-2008, 02:22 PM
mainpage code

<code>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<body topmargin="0">
<div align="center">
<div align="left">
<table width="100%" cellpadding="0" bgcolor="#FFFFFF">
<tr>
<td height="37" colspan="2" align="center" valign="middle"><HR SIZE=4 color="#990000" ></td>
</tr>
<tr>
<td width="47%" height="162" align="center" valign="top"> <div align="center">
<table width="264" height="430" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle">

<script type="text/javascript">
ajaxinclude(includefiles, "random")
</script></td>
</tr>
</table>
<br>
ajax content should be above here<br>
<strong></strong></div></td>
<td width="53%" rowspan="3" align="left" valign="top"> <div align="left">
<!-- featured_products_mainpage //-->
<!-- featured_products_eof //-->
</div></td>
</tr>
<tr>
<td align="center" valign="middle">&nbsp;</td>
</tr>
<tr>
<td align="center" valign="top"> <font color="#333333" size="4">&nbsp;</font></td>
</tr>
<tr>
<td height="41" align="center">&nbsp;</td>
<td align="left" valign="top"><div align="center"> </div></td>
</tr>
</table>



</div>
</div>
<code>

meakip
04-27-2008, 02:33 PM
I managed to get it working in an HTML page here

http://www.pinkspiderdirect.com/ajax.htm

meakip
04-27-2008, 07:25 PM
The link to the dynamicdrive script does not work for some reason now so here it is again

http://www.dynamicdrive.com/dynamicindex17/ajaxrotate.htm

meakip
04-28-2008, 03:27 AM
Hello, still no luck in getting this to work, I am desperate to get this code working please help, any suggestions are very welcome, being a novice at this game this one is a real struggle.

Many thanks for any help or time taken to have a look at this code.

Patrick