Manipulating Category globalOrder

7 posts by 2 authors in: Forums > CMS Builder
Last Post: August 21, 2014   (RSS)

Hello, All

Is there a way to manually adjust the category globalOrder outside of CMSB? I've created a page which allows users to create and edit category pages through a simple form. It works very well. The only thing missing is a means of moving the newly created page up and down in the hierarchy. I though I could simply send a value directly to the database - but that doesn't seem to work.

In the old days of CMSB (before dragSortOrder came along) moving categories was done by using "up" and "down" links. Is there a way for me to use a similar approach on my form?

:o/

Perch

Hey Perch,

Unfortunately, this will be a fairly difficult system to implement. If you wanted to add move up / move down links, you could look at duplicating the functionality of the categoryMove function, which you can find on line 414 of /lib/common.php. 

This function requires the following items to be sent over in a form and available in the request array:

  • menu: The section name that you want the items reordering on. 
  • sourceNum: The num value of the record you want to move.
  • targetNum: The num value that the item will now be above/below.
  • position: Will the source item be above or below the target item? Send over 'above' or 'below' to show the new location. 

You could use the getPrevAndNextRecords to get the previous and next target num values for the next previous links.

Thanks,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Greg -

Thanks for taking a look. Is there another way to achieve what I'm trying to do? Maybe I'm going about it the wrong way?

Perch

Greg -

Would it be possible to re-order the output from the database, as opposed to trying to re-order the database itself?

Just a thought.

Perch

Hey Perch,

I think you're better off changing the order of the items in the database as opposed to using PHP to re-order them afterwards. I think copying and amending the categoryMove function is probably the best option. Would it be possible to give me a few more details what you're using this system for? I guess there is a reason you can't allow users to change the order via the CMS. 

Thanks,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Hey Perch,

That's a good idea! I've had a look to see if I could write some quick demo code that would make some move up / down links. But it's more complicated than I initially thought and will be quite time consuming to create (probably an hour or two).

If you send an e-mail to consutling@interactivetools.com, we can give you a price to implement this system.

Thanks!

Greg 

Greg Thomas







PHP Programmer - interactivetools.com