Fileset sortable display order. HOW TO?

Permalink 3 users found helpful
Does anybody know how to display images from a filset in display order. This is a new function in C5 v5.4. In Dashboard->FileManger->FileSets->Edit you can now change the display order for your files.

BUT ... HOW TO GET THE DISPLAY ORDER. I Want to build a custom gallery block etc.

Mireck78
 
SVijay replied on at Permalink Best Answer Reply
SVijay
Hi,

You can use
$l = new YourSearchList();
$l->sortBy($key, $dir)
 or
$l->sortByMultiple($field1, $field2, etc…)
etc

For more details have a look at the given link, it may help you
http://www.concrete5.org/documentation/developers/system/searching-...
Mireck78 replied on at Permalink Reply
Mireck78
Wow that's it! Thanks a lot ... her is my function to get (echo) all images from an FileSet in display order:

Loader::model('file_set');
Loader::model('file_list');
/*
* Returns an array of all ImageFileObjects from an given FileSet in display order
* $fsId:INT the filsetID
*/
function getImagesFromFileSet($fsId) {
   $myFileSet = FileSet::getByID($fsId);
   $myFileList = new FileList(); 
   $myFileList->filterBySet($myFileSet); 
   $myFileList->filterByType(FileType::T_IMAGE);     
   $myFileList->sortBy("fsDisplayOrder", 'asc'); 
   $myImages = $myFileList->get();
   return $myImages;
}



I use it in conjunction with
$images = getImagesFromFileSet($fileSetID);
   function echoGalleryImages($images) {
      for ($n = 0; $n < count($images); $n++) {
         echoImage($images[$n]); 
      }
   }
   function echoImage($file) {
      $src = $file->getRelativePath();
      $alt = $file->getTitle();
      echo "<img alt='$alt' src='$src' />";
      //echo $src . "<br /><br />";
   }
SVijay replied on at Permalink Reply
SVijay
Please can you make my answer. I am trying to build up my profile.

Thanks Vijay