Instead of using an order field, would this work? This method uses 3 custom states and “rebuilds” it. I’ve found working with lists tricky without using plugins like ListShifter/Floppy (sp?).
Step 1: User Selects Artworks
- Create a repeating group listing all user-owned artworks.
- Add a custom state on the page (e.g.,
Selected_Artwork) of type Artwork (list).
- When a user clicks on an artwork to include, run a workflow:
- Action: Set
Selected_Artwork = Selected_Artwork :plus item Current cell's Artwork.
- After the user is done selecting, run a workflow (e.g., on “Save” button) to store
Selected_Artwork into the Portfolio’s Featured Artwork field:
- Action:
Make changes to Portfolio: Featured Artwork = Selected_Artwork.At this point, the Portfolio’s Featured Artwork list is saved in the order the user selected.
Step 2: Set Up the Drag and Drop Interface
- Create a repeating group to display
Portfolio’s Featured Artwork.
- Inside each cell:
- Add a Drop Area (from the Draggable Elements plugin).
- Inside that Drop Area, place a Drag/Drop Group containing the artwork’s image/text.
- This setup allows users to drag one artwork over another, triggering drop events.
Step 3: Handling the Drop Event to Reorder
When the user drops an artwork onto another cell’s drop area, you’ll run a workflow to reorder the Selected_Artwork list:
- Get the Drop Location Index:
- Create a workflow triggered by the drop event.
- First, store the “index before drop” in a custom state, say
State_Dropped_Index-1.
- Action:
Set state State_Dropped_Index-1 = Drop Area’s current cell index - 1.
- Create Three Lists Using States:
- Artwork Before Drop:
Take Selected_Artwork up to State_Dropped_Index-1 (this gives everything before the new position), and remove the dragged artwork if it appears there.
- The Dragged Artwork:
This is the current workflow’s artwork.
- Artwork After Drop:
Take Selected_Artwork from the drop index to the end of the list, removing the dragged artwork if it’s there.Use custom states to hold these segments. For example:
State_Artwork_Before = Selected_Artwork:items until #State_Dropped_Index-1 :minus item Current Workflow’s Artwork :plus item Current Workflow’s Artwork
State_Artwork_After = Selected_Artwork:items from #Current Cell’s Index to end :minus item Current Workflow’s Artwork(You may adjust these exact expressions based on your indexing logic.)
- Rebuild the List in the New Order:
After setting these states, merge them back into Selected_Artwork:
Selected_Artwork = State_Artwork_Before merged with State_Artwork_AfterNow Selected_Artwork reflects the newly ordered list.
Step 4: Handling the Last Position Drop
To allow dropping an artwork at the very end of the list:
- Add an extra Drop Area after the last cell of the repeating group.
- On drop into this final Drop Area:
- Simply take
Selected_Artwork :minus item Current Artwork :plus item Current Artwork to put the dragged artwork at the end.
Step 5: Saving the New Order
If desired, once the user is happy with the new order, they can click a “Save” button:
- Action:
Make changes to Portfolio: Featured Artwork = Selected_Artwork.