unable to access image folder
Posted: Tue Oct 08, 2019 11:35 am
I'm trying to display images from this folder
I have a custom field for the name of the folder since the user should be able to add different names of folders for each article. (im using the News module)
The custom field is called picfolder.
So in my news detail template I have this tag
{list_images url='{$entry->picfolder}'}
The problem is that I always get a list of some files on the root. but not the image files I want to display.
what am I doing wrong here?
to do that I'm using this snippet, which I got from https://cmscanbesimple.org/blog/list-images :uploads/images/mypicfolder
Code: Select all
$url = isset($params['/uploads/images/ ']) ? $params['/uploads/images/ '] : '';
$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";
The custom field is called picfolder.
So in my news detail template I have this tag
{list_images url='{$entry->picfolder}'}
The problem is that I always get a list of some files on the root. but not the image files I want to display.
what am I doing wrong here?