Welcome Guest, Not a member yet? Register   Sign In
CI + DataMapper + sort relationships
#4

[eluser]BrianDHall[/eluser]
Oooo, do you want custom sort ordering, I see.

In that case you need another table column, and you need some way to manipulate it. You can use default sort order to sort by this display_order field.

Then, however you have to have some sort of interface and logic for setting and changing such things. There is nothing in MySQL that supports this sort of functionality outside of a special field, so Datamapper can't really do much about it.

What I do is use this field and then allow the user to assign values to things in simple text fields. I didn't want fancy javascripting so a person can either just be happy assigning a bunch of things to the default value of say, 50 - then if they want something below everything else they set it to a higher number, and if they want it higher they set it to a lower number.

You could also do a "move up" selection form, then have your model control the logic of "this is number 5 and needs moved up, so set field number 4 to field 5 and then set this field to 4...". The fancy whizz-bang feature would be a javascripted list that allows selections to be moved up and down, or even dragged and drop would be cool. Then when you click submit it submits IDs in the order they appear - then you have your model go through and assign the display_order based on order of the reordered list, and there you go.

I've been intending to build a feature like this myself, just haven't needed it badly enough to want to go to the trouble of a more robust, end-user friendly system as it is just for my admins and me to use.


Messages In This Thread
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 08:13 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 08:53 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 10:09 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 10:20 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 10:31 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 11:12 AM
CI + DataMapper + sort relationships - by El Forum - 11-05-2009, 04:42 PM
CI + DataMapper + sort relationships - by El Forum - 11-09-2009, 06:32 PM
CI + DataMapper + sort relationships - by El Forum - 11-09-2009, 07:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB