This is the process I have been using for years, not that exact
JavaScript but still the same idea.  I tend to have a SortOrder column
in my tables with a default value of 0. As I add new records I put in
the max sortorder + 1 and then my admin tool via a select box allows
me to reset the ordering if I ever desired to.


On Fri, 10 Dec 2004 15:39:31 +0100, Mark Drew <[EMAIL PROTECTED]> wrote:
> As I mentioned in my previous post. the solution is to reorder all the
> items in a set at once. By using the select box you dont need that
> kind of math. :)
> Also (I think) the javascript toolbox that I posted allows you to drag
> items up (I think!) and its a bit more intuitive.
> 
> As part of the display I would also put the original order and the
> ordering box side buy side so that the user can see what the change
> would be
> 
> Old Order       New Order
>                ---------
> Item 1          |Item 1 |
> Item 2          |Item 2 |  ^
> Item 3          |Item 3 |  v
> Item 4          |Item 4 |
>                ---------
> 
> hope that helps!
> 
> Regards
> 
> 
> 
> Mark Drew
> 
> On Fri, 10 Dec 2004 09:21:00 -0500, Rick Root <[EMAIL PROTECTED]> wrote:
> > Stuart Kidd wrote:
> > >
> > > On my website i have 23 articles on the front page, i'd like to be able 
> > > to position them.  Say the article which pulls out the database in 
> > > position 18, i'd like to move up a notch to 17, what is the cleanest way 
> > > to do this.
> > >
> > > I have all my articles on this front page (http://www.020.com/).
> > >
> > > I have a CMS i created.  I have thought of ideas of having a field called 
> > > Position or something but can't find an easy solution.
> >
> > Stuart, in my community publishing software, each page is made of
> > multiple postings, which appear vertically on the page.
> >
> > In order to accomplish the ability to control the order in which they
> > appear, I added a POSTING_ORDER numeric field... this allows me to move
> > things up and down on the page, and also allows me to insert new
> > postings at the top, bottom, or in between existing postings.
> >
> > The tricky part was figuring out the math!
> >
> > In pseudo code....
> >
> > get posting order of current posting
> > get posting order of the bottom post
> > if action = up and posting order > 1
> >    moveto = posting order - 1
> >    swap two postings by running the queries:
> >    query: set posting_order += 1 where posting_order = moveto
> >    query: set posting_order = moveto where posting_order=original
> >         posting_order
> > if action = down and posting order < bottom
> >    moveto = posting order + 1
> >    swap two postings by running the queries:
> >    query: set posting_order -= 1 where posting_order = moveto
> >    query: set posting_order = moveto where posting_order=original
> >         posting_order
> >
> > It gets a little more complicated if you also want "move to top" and
> > "move to bottom"
> >
> >   - Rick
> >
> >
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:186972
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to