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

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

By Perchpole - August 21, 2014 - edited: August 21, 2014

Hi, Greg -

I've developed a really useful front-end form system which allows users to create and edit categories. It means they never have to use the CMSB back-end (which some find intimidating). They simply edit the text and options on the page of the website and save it.

Everything works fine. The only thing I can't do is give them the power to move a category in the globalOrder.

In practise, if the user creates a new top level category, it will be added last in the database. This means the new category will be rendered at the end of the navigation menu. If we were to use the nav on this page as an example, above, the new category would appear to the right of the "ABOUT" link.

What I want to do is give the user a way of nudging the new category to the left.

:0)

Perch

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