MENU

List of images

  Previous article Next article  

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!



  Show related articles:


  Comment Form

Click here to open the form


  0 Comments

No comments yet...

CMS Made Simple - Tutorials, tips and tricks - CMSMS

List of images

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 1.11.4
  Last updated: 23-06-2018
  Comments: 0
  http://cms.ms/dTxq

Advertisement



Ads help me to help you! Thanks!

Ads help me to help you! Thanks!

Ads help me to help you! Thanks!