sortable

edited September 2014 in Modules
I am thinking to implement sortable list in fuel cms, is there any built in already?

Comments

  • edited 7:55PM
    Do you mean you want to sort list items for a module in the CMS? If you add a column called "precedence" (storing integers) in the database table, it will allow sorting automatically.
  • edited September 2014
    There is also a "sorting" parameter you can use on a "multi" field type that will allow you to select and then sort that selection:
    http://docs.getfuelcms.com/general/forms
  • edited 7:55PM
    thanks all, how can i make a "multi" field allow sorting only, which means there will not have two box side by side to select left side items to right side then sort, but only left box allow sorting?
  • edited 7:55PM
    You can't unfortunately. You could create your own custom field to to do that though:
    http://docs.getfuelcms.com/general/forms#association_parameters
  • edited March 2018
    The multi field sorting order in the right hand list doesn't seem to be related to the precedence column. What i would like to be able to do is sort right hand side (selected) items, and then save the precedence value back to the source table (either by ajax or stored field). On reload of the admin page the selected (right hand) list would be in precedence order.

    However, the list elements also don't seem to have any relation to their primary key (eg a data-id value) but do have their original sort index in a nested span (?), so I suppose a script could note the difference in the new node order to the span integer and work out a precedence value based on that. The string value for data-label seems to be the only identifier to the table row though.

    Even if that were a workable solution (match data-label to primary key to post precedence value) the right hand sort order seems to default to alpha not precedence. Has this problem been solved by anyone?
  • edited 7:55PM
    Just to confirm, you have the set the field's parameter of "sorting" to true?

    You could use an on_after_save model hook to loop through the multi field's value IDs (they should be in the order in which they were sorted) and then retrieve those records by ID (e.g. $my_record = $my_model->find_by_key($id)) and then save the precedence value which would be the ID's associated index value. Does that make sense?
Sign In or Register to comment.