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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.