Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need some help with javascript & php please re Slideshow in a theme
#7
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';
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);
?>
    ];
It works a treat in the standalone sample page but when I put it into my GS template.php I get nothing.
Reply


Messages In This Thread
RE: Need some help with javascript & php please re Slideshow in a theme - by Timbow - 2012-11-17, 04:08:16



Users browsing this thread: 1 Guest(s)