2012-11-17, 04:08:16
Yes, if I manually write the filenames into the array the slideshow works alright, but the php is supposed to read the files in the folder and generate the array. That's what I can't get to work.
It's this section that I don't know what to do with. I always get an empty array, even when I define $s_path = 'http://fullpathtoimages';
It works a treat in the standalone sample page but when I put it into my GS template.php I get nothing.
It's this section that I don't know what to do with. I always get an empty array, even when I define $s_path = 'http://fullpathtoimages';
Code:
// list of images to display
var A_ITEMS = [<?php
$s_path = 'img/';
$a_types = array ('jpg', 'gif', 'jpeg', 'png');
$a_images = array ();
$h_dir = opendir($s_path);
while ($s_file = readdir($h_dir)) {
$s_type = strtolower(substr(strrchr($s_file, '.'), 1));
if (in_array($s_type, $a_types))
array_push($a_images, "\n\t\t'$s_path$s_file'");
}
closedir($h_dir);
sort($a_images);
echo join(',', $a_images);
?>
];