Hi again
Another thing I'm trying to do with Matrix at the moment is to set up an asset listing where users are able to move things around the listing themselves.
I've managed to do this with using a custom metadata 'order' field which gets used in the listing order.
However, how can I put little buttons next to each asset in the listing to move it up and down? I was thinking of using a trigger somehow to change the order metadata value up or down one when a button is pressed. But I have no idea how to make the button fire a trigger. Do I even need to use triggers?
Maybe things like this are pretty advanced and not at all easy to do.
If anyone has some example code of doing this type of thing, that would be a great help.
cheers
It sounds like you want to use an AJAX-type functionality.
I don't have code snippets, but you could create buttons that send an AJAX request to the asset you want to change the order of, that in turn fires a trigger action on that asset to change the 'order' metadata field (to a value which can you would specify in the query string).
The magic would all happen with Triggers, and you could use JavaScript to re-order the listing items without reloading the page.
Alternatively, if you didn't want to use AJAX, the button could link to the asset using a user-defined design (http://foo/asset?SQ_DESIGN_NAME=bar), which simply fires the triggers and the design prints a redirect to take you back to the previous page immediately.
Note that to calculate the position of the item and construct the correct query string, you'd need to use JavaScript. There is a new Trigger action which should be out fairly soon that does arithmetic calculations on metadata (removing the need for any position calculations in this situation).
This sounds slightly complicated, but it is possible! 
[quote]Maybe things like this are pretty advanced and not at all easy to do.
If anyone has some example code of doing this type of thing, that would be a great help.[/quote]
Or, if you wanted to get even more complicated, just for fun, you could send XML to the asset map with the correct order of your assets. Then, if you have your asset listing set to no sorting, and direct links only, you will get the sorting that the asset map has. So, you just need to send a resorted XML to the asset map, and you have your new sort order.
Greg and I talked about this a bit ago.
[quote]Or, if you wanted to get even more complicated, just for fun, you could send XML to the asset map with the correct order of your assets. Then, if you have your asset listing set to no sorting, and direct links only, you will get the sorting that the asset map has. So, you just need to send a resorted XML to the asset map, and you have your new sort order.
Greg and I talked about this a bit ago.[/quote]
ok thanks. It does sound a little complicated, but worth a try.
The reason I’m interested in this is because we really need to have a menu system which can be somewhat independent of the site structure. So users can add new pages and then decide on the frontend not only whether to put them in the menu, but where to put them. All this won’t affect the structure of the site itself.
I know this might sound weird, but it is in fact a useful feature. In effect it means the way people navigate a site has little to do with how content is structured behind the scenes.