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 Silver Sponsor - CFDynamics http://www.cfdynamics.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:186968 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