Okay, slideshow.php defines 2 variables, $array1 and $var2.
slideshow.php is then included in header.php in the normal include manner.
header.php contains 1 check against the existence of $array1.
footer.php also contains 1 check against $array1 and if it exists, prints $var2.
Even though $array1 exists and is printed by slideshow.php within itself, it fails the check by $header.php and $footer.php.
If I just paste the code from slideshow.php into header.php rather than include it, then $array1 passes the check on header.php, but still not on footer.php.
What’s up with that? :-D
Here's a further description of how the files associate...
- slideshow.php is included in header.php
- header.php and footer.php are included in just about every other public file on the site. header.php contains all the code before the main content info of a page and footer.php everything after. You get the idea.
I should add that the slideshow.php file is definitely being included. The jscript is printed with the php code being parsed correctly within the slideshow.php file. Where the jscript array for the images is built by the php. That's working fine and being shown correctly if I view the source of the final page in a browser.
Below is the code for slideshow.php and subsequently the places in header.php and footer.php where variables from slideshow.php are called:
<?php
//Get image names from folder
$imageFileLoc = opendir($siteBasePath.'images/slideshow-images/');
while (false !== ($imageFile = readdir($imageFileLoc))) {
if (($imageFile != '.DS_Store') && ($imageFile != '_notes')){
$imageFiles[] = trim($imageFile);
}
sort($imageFiles);
}
closedir($imageFileLoc);
//Setup slideshow placeholder
$slideShow = '<table border="0" cellpadding="0" cellspacing="0">' .
'<tr>' .
'<td id="VU" height=160 width=124>' .
'<img src="'.$imageFiles[1].'" name="SlideShow" width=160 height=124></td>' .
'</tr>' .
'</table>';
?>
<script>
// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully
// =======================================
// set the following variables
// =======================================
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 5000
// Duration of crossfade (seconds)
var crossFadeDuration = 3
// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below
<?php
//Get filenames from slideshow folder
for ($i=2; $i < count($imageFiles); $i++){
$picIndex = $i - 2;
print "Pic[".$picIndex."] = '/images/slideshow-images/".$imageFiles[$i]."';";
}
?>
// =======================================
// do not edit anything below this line
// =======================================
var t
var j = 0
var p = Pic.length
var preLoad = new Array()
for (i = 0; i < p; i++){
preLoad[i] = new Image()
preLoad[i].src = Pic[i]
}
function runSlideShow(){
if (document.all){
document.images.SlideShow.style.filter="blendTrans(duration=2)"
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
document.images.SlideShow.filters.blendTrans.Apply()
}
document.images.SlideShow.src = preLoad[j].src
if (document.all){
document.images.SlideShow.filters.blendTrans.Play()
}
j = j + 1
if (j > (p-1)) j=0
t = setTimeout('runSlideShow()', slideShowSpeed)
}
</script>
Header.php
between the head tags to include the jscript:
<?php fileInclude('/php-bin/slideshow.php'); ?>
AND in the body to load the slideshow jscript if there is an array:
<?php print ((is_array($imageFiles))? '; runSlideShow()' : ''); ?>
Footer.php
Where the slideshow is placed:
<?php print ((is_array($imageFiles))? $slideShow : '<img src="/images/page_photo.png" />'); ?>
Thanks!
Matt