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: 13-01-2015
  Comments: 0

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!


A2 Webhosting CMS Made Simple

  Comments

  Click here to leave a comment






This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
  « Enter the CAPTCHA code (lower case)

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!
In case of abuse your IP address will be blocked!


Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!!
Consider buying Rolf a cup of coffee in return! [ Click here ]


  0 Comments

No comments yet...

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

List of images

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 1.11.4
  Last updated: 13-01-2015
  Comments: 0

A2 Webhosting CMS Made Simple