List of images

  Previous article Next article  

List of images

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 1.11.4
  Last updated: 18-11-2017
  Comments: 0
  http://cms.ms/dTxq

An 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";

  How to use

Add in your page:

{list_images url='path/to/your/folder'}

Change the url in the tag to your own!




CMS Made Simple 2.2.5 - Tutorials, tips and tricks - CMSMS 2.2.5

List of images

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 1.11.4
  Last updated: 18-11-2017
  Comments: 0
  http://cms.ms/dTxq