List of images
Previous article Next articleAn example User Defined Tag which reads the images in a folder and shows it in a unordered list. With JQuery, Fancybox and some styling you can use it to create a simple photogalery. The article is only about the User Defined Tag, the required extra functionality is not included!
This article originates from the former CMSMS Wiki, the original author is Elijah Lofgren. I cleaned the code and added code to *not* read thumb images in the folder.
User Defined Tag, named "list_images"
$url = isset($params['url']) ? $params['url'] : '';
$dir = cmsms()->config['root_path'] . DIRECTORY_SEPARATOR . $url;
echo "<ul>\n";
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if ( ('file' == filetype($dir . $file)) && (substr($file,0,6) != 'thumb_') )
{
echo '<li><a href="'.$url.$file.'" class="fancybox"><img src="'.$url.'thumb_'.$file.'" alt="'.$file.'" /></a>'."</li>\n";
}
}
closedir($dh);
}
}
echo "</ul>\n";
$dir = cmsms()->config['root_path'] . DIRECTORY_SEPARATOR . $url;
echo "<ul>\n";
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if ( ('file' == filetype($dir . $file)) && (substr($file,0,6) != 'thumb_') )
{
echo '<li><a href="'.$url.$file.'" class="fancybox"><img src="'.$url.'thumb_'.$file.'" alt="'.$file.'" /></a>'."</li>\n";
}
}
closedir($dh);
}
}
echo "</ul>\n";
How to use
Add in your page:
{list_images url='path/to/your/folder'}
Change the url in the tag to your own!
Comment Form
ReviewManager
ReviewManager
0 Comments
No comments yet...