• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: unable to access image folder
PostPosted: Tue Oct 08, 2019 11:35 am 
Offline
Forum Members
Forum Members

Joined: Wed Aug 08, 2018 4:59 pm
Posts: 52
I'm trying to display images from this folder

\$1:
uploads/images/mypicfolder


to do that I'm using this snippet, which I got from https://cmscanbesimple.org/blog/list-images :
\$1:
$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";


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?


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: unable to access image folder
PostPosted: Wed Oct 09, 2019 7:49 am 
Offline
Support Guru
Support Guru
User avatar

Joined: Wed Sep 05, 2007 8:03 pm
Posts: 4008
Location: The Netherlands
$params['/uploads/images/ '] is not a correct modification of the original code

_________________


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: unable to access image folder
PostPosted: Wed Oct 09, 2019 9:33 am 
Offline
Forum Members
Forum Members

Joined: Wed Aug 08, 2018 4:59 pm
Posts: 52
I'm aware of that, I've tried all kinds of paths but with out any luck.
Could you please guide me on what would be the correct modification to access the image folder?


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: unable to access image folder  Topic is solved
PostPosted: Wed Oct 09, 2019 4:24 pm 
Offline
Support Guru
Support Guru
User avatar

Joined: Wed Sep 05, 2007 8:03 pm
Posts: 4008
Location: The Netherlands
Try this:

\$1:
$url = isset($params['url']) ? $params['url'] : '';
$dir = cms_join_path(cmsms()->config['image_uploads_path'], $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";


And use tag: {list_images url=$entry->picfolder}

_________________


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
 Post subject: Re: unable to access image folder
PostPosted: Thu Oct 10, 2019 11:08 am 
Offline
Forum Members
Forum Members

Joined: Wed Aug 08, 2018 4:59 pm
Posts: 52
Thanks Jos for your help
This works but I ended up using another solution which gives the same result.


Top
  Profile  
 
Share On:
Share on Facebook Share on Twitter Share on Google+
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
A2 Hosting