Topic: Load images in via HTMl

Hi,

I would like to be able to load my images via html rather than via the xml file is this at all possible to do with simple viewer?

I ask because i am running a mysql query on my image database and only pull out certain images for each page.  I would like to load these into simpleviewer at page load.

Thanks
Fraser

Re: Load images in via HTMl

SimpleViewer requires an XML file to either list the images for the gallery or set the Flickr options.
You could, however, use PHP to dynamically generate a custom XML file on-the-fly.
The embedding code should point towards a PHP file for the galleryURL, eg:

<!--START SIMPLEVIEWER EMBED.-->
<script type="text/javascript" src="svcore/js/simpleviewer.js"></script>
<script type="text/javascript">
var flashvars={};
flashvars.galleryURL="gallery.php";
jQuery(document).ready(function () {
SV.simpleviewer.load("sv-container", "100%", "100%", "222222", true, flashvars);
});
</script>
<div id="sv-container"></div>
<!-- END SIMPLEVIEWER EMBED -->

The file 'gallery.php' would contain the PHP code to generate the XML file.
This solution would require knowledge of PHP and your web server would have to have PHP installed.

Steven Speirs
SimpleViewer Support Team.

Re: Load images in via HTMl

Hi ,

Thanks for the reply,

Can you point me in the direction of an example gallery.php file.  I found one on the forum ( i think) but it seems to be related to an older version of simpleviwer.

Thanks
Fraser

Re: Load images in via HTMl

As an example and a starting point for your own project, the following PHP code will dynamically build the XML file to include all images in a folder named 'images'.

<?php
function GetDirArray($folder)
{
    $handle=opendir($folder);
    while ($file=readdir($handle))
    {
        if ($file!="." && $file!="..")
        {
            $ret[count($ret)]=$file;
        }
    }
    closedir($handle);
    sort($ret);
    return $ret;
}
$gallery=GetDirArray('images');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<simpleviewergallery title="SimpleViewer Gallery">';
for ($i=0; $i<sizeof($gallery); $i++)
{
    echo '<image imageURL="images/'.$gallery[$i].'" thumbURL="images/'.$gallery[$i].'" linkURL="" linkTarget="">';
    echo '<caption></caption>';
    echo '</image>';
}
echo '</simpleviewergallery>';
?>
Steven Speirs
SimpleViewer Support Team.