Fileset Order

Permalink 1 user found helpful
I created a custom gallery block with jordanlev's "C5 Designer Gallery" script. It's working, but it's not displaying the images in the order I want. There will always be exactly 5 photos, but those photos may need to be replaced from time to time. I only have the option to display in upload order or randomly. What is the best and easiest way to get them to always display in the order that I want? I figured there was a display order you could set in each set, but I don't see anything like that. Thoughts?

 
adajad replied on at Permalink Best Answer Reply
adajad
Sort on title in the controller? This is what I have done in a block based on the same Designer Gallery where I needed the images to be in order. Of course, you will need to change the title on your images in the file manager.

I added this function:
/****
* Returns array with image sources sorted on title.
****/
   private function getImgSrc($images){
      $imgSrc = array();
      foreach ($images as $img){
      $imgSrc[$img->title] = $img->large->src;
   }
   ksort($imgSrc);
   return $imgSrc;
}


and added this to the view() function
$imgSrc = $this->getImgSrc($images);
$this->set('imgSrc', $imgSrc);


I was only interested in the source, but you might still find it useful.
newfive replied on at Permalink Reply
Thanks for this, I may need it in the future! I just noticed, and this may be new in 5.5, but when you go to /dashboard/files/sets/ you can click on the set, then click "Files in Set" and you can drag and drop the order you want them to display in. I thought, surely the C5 guys would have that option somewhere, but I couldn't find any docs about it. That was easy! :)
StevieB replied on at Permalink Reply
Haha, almost five years later, but you have just saved me a whole heap of hair pulling! Why is this not a little more obvious or intuitive? This is something a client might want to do for themselves and I know I will get the glossy eyed look when trying to explain it! BTW, it is version 5.7.5.13 now and this is still the same…

Thanks for this post, and for saving what is left of my hair!!