<![CDATA[ Snippet return for directory contents - My Forums]]> https://forums.modx.com/thread/?thread=24276 <![CDATA[Re: Snippet return for directory contents]]> https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-465544 I did look at FileLister but it didnt seem to want to read from the external ftp address.

could the above script be modified ?

this resource will be behind a login so im not worried about security issues.]]>
bigben83 May 07, 2013, 12:41 AM https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-465544
<![CDATA[Re: Snippet return for directory contents]]> https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123669
             $output .= '<li><a href="'.$dir.''.$value.'" rel="sexylightbox[group1]"> <img src="[[MiniPhoto? &file=`'.$dir.''.$value.'` &dir=`mini` &height=`130`]]" /></li>';


thats the right way,

Thx]]>
Neutron Jul 09, 2009, 05:25 AM https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123669
<![CDATA[Re: Snippet return for directory contents]]> https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123668
         $output .= '<li><a href="'.$dir.''.$value.'" rel="sexylightbox[group1]"> <img src=[!MiniPhoto? &file=`"'.$dir.''.$value.'"` &dir=`mini` &height=`130`!] /></li>';


is this possible? or there is another way to make thumbs on the fly inside a snipped?
I’ve tryed this and the thumbs are not generated, folder is in 777,.. any idea? (I know there is maxigallery but I want to use jcarousel and sexylightbox with it..

Hope someone can help me! hehehe sad I dont want to make the thumbs manually!.. thx smiley]]>
Neutron Jul 09, 2009, 03:39 AM https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123668
<![CDATA[Re: Snippet return for directory contents]]> https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123667
<?php
/* -------------------------------------------------------------
:: Snippet: Returns Directory Contents
----------------------------------------------------------------
    Short Description: 
       Returns Directory Contents, excludes self, parent, ftp log and thumbnail with prefix (.thumb_)

    Date:
        05/16/2008

----------------------------------------------------------------
:: Example Call             
----------------------------------------------------------------
[!directory? &Location=`yourdirectory`!]
    A call that describes the directory inside of assets/images/ that you want called in.

------------------------------------------------------------- */

// Shows all files in the directory (assumes you are in assets/images/),

$newline = '';

$dir = $modx->config['(site_url)'].'assets/images/'.$Location.'/'; // set path to files

$dir_array = array(); // main array - contains all file names in directory


// open directory and parse file list 

if (is_dir($dir)) { 

   if ($dh = opendir($dir)) { 

      // iterate over file list to create full directory array

      while (($filename = readdir($dh)) !== false) { 

          if (($filename != ".") && ($filename != "..") && ($filename !="WS_FTP.LOG") && (!preg_match('/^.thumb_/', $filename))) { // skip self, parent, and ftp log and thumb prefix
		  
	       $dir_array[] = $filename; // add the filename to the array
          } 
      } 
      closedir($dh);  // close directory 
   }

   natsort($dir_array); // sort in ascending order -- delete if you don't need them sorted.
   // $dir_array = array_reverse($dir_array, false); // reverse array (descending) if needed.

   $n = count($dir_array); // total number of files -- might want this for something

    $output = '';

    $output .= '<ul id="mycarousel" class="jcarousel-skin-tango">';

    foreach ($dir_array as $value) {  // iterate through array of filenames.

         $output .= '<li><img src="'.$dir.''.$value.'" /></li>';

    } 

    $output .='</ul>';
    
}

return $output;
?>
]]>
pleth May 16, 2008, 11:07 AM https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123667
<![CDATA[Re: Snippet return for directory contents]]> https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123666 pleth May 15, 2008, 02:36 PM https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123666 <![CDATA[Re: Snippet return for directory contents]]> https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123665 twitter and I gave him the correct pattern to add to BobRay’s post.

I changed the following:
if (($filename != ".") && ($filename != "..") && ($filename != "WS_FTP.LOG")) { // skip self, parent, and ftp log

to
if (($filename != ".") && ($filename != "..") && ($filename != "WS_FTP.LOG") && (!preg_match('/^.thumb_/', $filename))) { // skip self, parent, and ftp log

And it works.

The pattern just checks to see if the filename starts with .thumb_ and if it does skip it.]]>
smashingred May 15, 2008, 02:16 PM https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123665
<![CDATA[Re: Snippet return for directory contents]]> https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123663
I am working w/ Greg on this and we think we almost have it. The only thing we want to do now is to exclude the .thumb_ file prefix so the thumbnails don’t show, do you have any suggestions for that?

We tried this,

if (($filename != ".") && ($filename != "..") && ($filename !=
"WS_FTP.LOG") && (!preg_match(’/^\.*thumb_$/’, $filename ) ) { // skip
self, parent, and ftp log and thumb prefix

and it didn’t seem to exclude them,
thanks for your help in advance.

Cotton Rohrscheib, Partner
Pleth Networks, LLC
http://www.pleth.com
]]>
powersitedesign May 15, 2008, 11:10 AM https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123663
<![CDATA[Re: Snippet return for directory contents]]> https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123662
I’ve adapted some code I had laying around. This is very quick and dirty code and untested, but should get you started.

<?php

// Shows all files in the directory,

$newline = "<br/>";

$dir = $modx->config['base_path'].'assets/yourfiles'; // set path to files

$dir_array = array(); // main array - contains all file names in directory


// open directory and parse file list 

if (is_dir($dir)) { 

   if ($dh = opendir($dir)) { 

      // iterate over file list to create full directory array

      while (($filename = readdir($dh)) !== false) { 

          if (($filename != ".") && ($filename != "..") && ($filename != "WS_FTP.LOG")) { // skip self, parent, and ftp log

		  	$dir_array[] = $filename; // add the filename to the array
          } 
      } 
      closedir($dh);  // close directory 
   }

   natsort($dir_array); // sort in ascending order -- delete if you don't need them sorted.
   // $dir_array = array_reverse($dir_array, false); // reverse array (descending) if needed.

   $n = count($dir_array); // total number of files -- might want this for something

    $output = "";

    $output .= "<ul>"

    foreach ($dir_array as $value) {  // iterate through array of filenames.

         $output .= '<li>'.$value.'</li>';

    } 

    $output .='</ul>';
    
}

return $output;

?>


BTW, you might look at the MaxiGallery snippet if you haven’t already. It does all this for you and makes for much easier and more full-featured gallery management by the users (e.g. picture order, uploading and deleting, titles, descriptions, dropshadows, masks, slideshow, etc).

Hope this helps,

Bob

]]>
BobRay May 14, 2008, 10:47 PM https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123662
<![CDATA[Snippet return for directory contents]]> https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123661
It seems this would create a gallery within Modx that the CMS user could manage by simply uploading to/deleting from a specified directory. Has anyone done anything like this?]]>
pleth May 14, 2008, 08:51 PM https://forums.modx.com/thread/24276/snippet-return-for-directory-contents#dis-post-123661