Jump to content

[SOLVED] Changing order of items in CMS. help with logic..


rreynier

Recommended Posts

Hey guys, I have created a little CMS project.

 

There are several cases where I have content that needs to be able to be moved to the top or down.. etc.  Right now, I just asdded a field called "order" and all my sql queries are doing "ORDER BY `order` ASC"

 

The way to change order is just to have the user change the number manually when editting the item..  So if you have 2 items.. one with the value 50 will be at bottom and one with value of 1, will be at the top.

 

I would like the user instead of having to put in a number in an input field, just be able to hit "move up" or "move down".

 

My question is, how would I go about this.  Im having a brainfree on how to do this logically.

 

Thanks ahead of time!

If they click move up, then find the one above it the one below it.  Then divide by two, and use the middle value.  So, if one is 10 and the other is 20, make it 15.  You can then infinitely have the order by using a float or double for the field instead of an int.

So, if the user clicks "move item up in order" find the next 2 entries that are higher in the list.  Add them together and divide by two?  So lets say the order value item is 16 and the next two are 17 and 18, I would get 17.5.  Could this possibly get out of hand decimal point wise?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.