jquery cycle slideshow images alphabeticaly, array won't work
Hi everyone,
I have used an online tutorial to make a slideshow using jquery cycle plugin.
the tutorial is located here: http://www.ampedwebstandards.com/2009/03/16/tutorial-dynamic-image-slideshow-with-php-jquery/
It all works, but the images are not displayed alphabetically. And I do want that.
I tried making an array of the image paths and sort that array alphabetically. That actually workes fine, but for some reason the cycle plugin won't turn the image tags in a slideshow anymore. Instead the images just display all together in a column on the page...
How to I get this to work, so that images are displayed alphabetically throughout the slideshow... ?
this is my modified code using arrays:
[PHP]
<?php
$directory = 'images/slideshow/';
try {
// Styling for images
echo "<div id=\"myslides\">";
foreach ( new DirectoryIterator($directory) as $item ) {
if ($item->isFile()) {
$path = "\"".$directory.$item."\"";
$imgpath = "<img src=".$path." />";
$imagearray[] = $imgpath;
}}
sort($imagearray);
$length = count($imagearray);
for ($i = 0; $i < $length; $i++) {
print $imagearray[$i];
}
echo "</div>";
}
catch(Exception $e) {
echo 'No images found for this slideshow.<br />';
}
?>
[/PHP]