How can I sort images?

Topics: General, XSLT
May 31, 2011 at 12:56 PM

Hi,

On a page, I create a list of images from the media archive. But I need the users to control the order in which the images are shown. I've attached a metatype to the page type, which enables the user to just select a media folder, and all images in that folder will be shown. But they can't control which image should be shown as the first image, second image and so on.

Is it possible to create a metatype with an integer field, and attach it to a mediatype? That way, the user can type in a number, and the system can use that number to sort the images before showing them.

Or is there another way?

Coordinator
Jun 1, 2011 at 10:15 AM

Your current solution (the user just uploads images in the media archive and when editing a page with a image list selects a folder with images in it) sounds pretty easy to maintain for the user - keeping as much of this simplicity as possible is a goal I guess.

You can't expand on the fields you see when editing images (adding extra meta data tom images). You can attach new forms/editors, tree commands and tree child elements -

Here are a few options - none perfect though:

  1. If titles are less important I would sort images on the title and then tell the user to control ordering this way.
  2. You can change the field where the user selects images from a DataReference<C1 Media Folder> to a huge string field and change the Widget to a multi selector widget (I'm skipping details here). This allow multiple items to be selected and ordered. When saved the multiple selections are saved as a comma separated string (ordered).
  3. You could also have some auxiliary functionality allowing your editors to order images in a folder and then correlate this ordering with images when you render.

Option 3 could perhaps be done by attaching a new command "Manage Image List ordering" to media folders (using the tree definition feature, see Attaching Actions and Auto attaching). You would then attach to media folders and then attach an action to the 'root' (making this action pop up on your media folders) which would invoke a ordering feature.