PDA

View Full Version : Simple Gallery is AWESOME - Can it read all jpgs from a directory?



dabilldoya
08-17-2009, 05:42 PM
1) Script Title: Simple Controls Gallery v1.3

2) Script URL (on DD): dynamicdrive.com/dynamicindex4/simplegallery.htm

3) Describe problem: I am in love with Simple Gallery. Although I'm a newbie I found it easy to set up and love the way it works on pages. My problem (if you can call it that...)

Is there a way to combine it with a script that will read all files in a directory and then build the slideshow presentation from that array? Another step further, can the description be the same as the file name?

My shortcut is to rename all photos in the 0001.jpg, 0002.jpg sequence and thats fine but if it could build the array by reading the directory files I wouldn't have to mess with that.

While I can build a file list in php I do not know how to plug it into the script for the slideshow. As you can see from below... I just make a mess of it...

<?php
$string="";
$fileCount=0;
$filePath=$PATH.'../images/'; # Specify the path you want to look in.
$dir = opendir($filePath);
while ($file = readdir($dir))
{
if (eregi("\.jpg",$file))
{
$string .= "[\"../images/$file\",\"\",\"\",\"$file\"],\n";
$fileCount++;
}
}

if ($fileCount > 0)
{
echo sprintf("<strong>List of Files in %s</strong><br />%s<strong>Total Files: %s</strong>",$filePath,$string,$fileCount);
}
?>

var mygallery=new simpleGallery({
wrapperid: "simplegallery1", //ID of main gallery container,
dimensions: [600, 600], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
//in the image array below, first is the picture, then link then target if needed
imagearray: [
<?php $string ; ?>
],

This is what I'm trying to do.....

My output is below......

<script type="text/javascript">
<strong>List of Files in ../images/</strong><br />["../images/0006.jpg","","","0006.jpg"],
["../images/0003.jpg","","","0003.jpg"],
["../images/0005.jpg","","","0005.jpg"],
["../images/0001.jpg","","","0001.jpg"],
["../images/0004.jpg","","","0004.jpg"],
["../images/0002.jpg","","","0002.jpg"],
<strong>Total Files: 6</strong>

var mygallery=new simpleGallery({
wrapperid: "simplegallery1", //ID of main gallery container,
dimensions: [600, 600], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
//in the image array below, first is the picture, then link then target if needed
imagearray: [
],
autoplay: [true, 6000, 2],
persist: false,
fadeduration: 3000,
oninit:function(){
},
onslide:function(curslide, i){
}
})


As you can see now it doesn't even recognize the $string variable...

This hodgepodge above is as close as I've gotten so far...

Is there a way to loop this so by entering <?php echo $string ; ?> in once it will read the entire directory and use the filename ($string) as the description?
Is this even possible???

Thanks for your time...

David

dabilldoya
08-18-2009, 02:12 AM
Please see this thread for resolution details.
Also integrated Pay Pal option list into solution.

For selling photos this fix works great.
Gallery now does slideshow presentation and populates the image #'s from that directory into the Pay Pal button. Fully automatic. Just enter the directory you want read and it's done.


http://www.dynamicdrive.com/forums/showthread.php?t=47709