Sort order in editors

10 posts by 2 authors in: Forums > CMS Builder
Last Post: February 15, 2018   (RSS)

By rez - February 1, 2018 - edited: February 5, 2018

 For a restaurant menu, i have a category editor with dragSortOrder sorting.

I have another editor for menu items. In this editor, one field is a list that uses the categories database to select a category for each menu item. This is set to dragSortOrder as well.

The code on my page loops through each item and if it matches a current category being displayed, it displays. Works fine. On my web page, all the categories are listed in the order I dragged them in the categories editor and so do the items. I can make it perfectly match the printed menu whenever they change something.

However, when updating a menu in the menu item's CMSB editor, the list is not sorted like the front end. Clicking the Categories header in the editor list doesnt sort the way I expect. I would like it to be displayed the same as the front end and the printed menu for ease of visual editing . In this huge item list, I would like all the categories in whatever order I have dragged them in the category editor which is working well for the front end. Is this possible? I dont understand what order they are currently in. The items within each category of the menu items editor list are sorted properly. However, maybe the categories are listed in the menu items editor in the order i created them or something? Does the order of the Categories in the category editor affect the menu items editor list at all? That's what I need.

Sorting for menu items editor:

First display dragSortOrder of categories, then dragSortOrder of menu items

Hope that makes sense.

By leo - February 1, 2018

Hi rez,

If I get it right, the categories and menu items worked fine with dragSortOrder before, and not working after you modified one of the menu items? Can you provide an example (link or screenshot) of how they were before and after edit? I suspect the issue may be the loop so if you can attach the loop code that will be great.

I will wait for your response :)

Leo - PHP Programmer (in training)
interactivetools.com

By rez - February 2, 2018 - edited: February 5, 2018

Hi Leo. I'm horrible at being clear even though I write a book, sorry.

No, the web page is fine. It's the CMS editor thats not listing them the way I want. I'm not sure if i have ever displayed the CMSB editor list like this before, it would just be nice in long lists.

Cat editor:

https://www.screencast.com/t/2jmgEoTuiMp

Menu items editor:

https://www.screencast.com/t/HVJIeIFjSI

Web Page:

https://www.screencast.com/t/LlLgT10Ape

See how the menu items editor is not sorted like the categories or web page? Why is Steak Toppers listing out after Appetizers? When I have a very long list of menu items and they make changes, if the CMS was in the same order, it would be much easier to overhaul a menu with an email or print in front of me. Making everything in sync, going down the list and checking off updates. Follow me? The only sorting I see is clicking the "Category" header in the editor list but that doesn't sort as desired.

By leo - February 2, 2018

Hi rez,

Ah I see what you mean by "clicking the category to sort". So when you click the "category" column to sort the list items:

1. They are sorted by the value of that field. I suspect in this case the value of field "category" is the num of Category records, which means it's basically sorting by category num value

2. It's not actually "sorted". It does not change the item order in the database nor the default item order returned by getRecords().

However, dragSortOrder actually changes the item order. If you go to CMS Setup > Section Editors > [Menu Item Section], on top click "sorting" tab, you should see "dragSortOrder DESC" by default. This defines when getRecords() is called, the default order of items will be dragSortOrder descendent. And you can modify this value to change how the list should be ordered by default.

Let me know if you have any questions!

Leo - PHP Programmer (in training)
interactivetools.com

By rez - February 2, 2018 - edited: February 2, 2018

In the menu items editor, I have sorting set to dragSortOrder:

https://www.screencast.com/t/Ykz1pRA17ch

In the category list (I added record num to be viewable in the list), Soups are dragged to the second position (actually, they happen to be record 2 already).

https://www.screencast.com/t/7WKKFtbiqa

So in the CMS menu items records list (even after clicking the column / category sort header), "Soups" is still not displaying as the second category. Steak Toppers is the second category showing:

https://www.screencast.com/t/BDx3VpjP

I must be misunderstanding your explanation. Should soups be second in this case? Even if it was sorting by num (not what I want),  Soups should be  #2. I'm not feeling too bright here. :D  It's all good, the food menu is now updated but I want to understand and believe it will be easier next time if I could get it sorted the way I want.

For an admin, I want the records list in screenshot 3 above to be in the same order according to how I have them in screenshot 2 above (category dragSortOrder). This would list Soups second.

By leo - February 2, 2018

Hi rez,

You got exactly what I mean and you were right. The "Soup" category should definitely be the second. I have a clue what might cause the issue but could you provide a screenshot of the setting of menu items' category field?  You should be able to find it under Section Editors > Menu Items, click "modify" link beside the category field, and take a screenshot of "Field Options".

Also, what is the 3rd category after "steak toppers" in your menu items list page?

Leo - PHP Programmer (in training)
interactivetools.com

By rez - February 2, 2018

Requested screenshot:

https://www.screencast.com/t/FIg2jSBwU

The 3rd category list showing in the menu items list is "Sides".

Thanks!

By leo - February 5, 2018

Hi rez,

I suspect the problem is that the category field is sorting by its string value, "1x" will be after "1" instead of "2" because the first digit is 1 which is smaller than 2. The fast solution will be changing this field to INT type. Go to CMS Setup > Section Editors > Menu Items and modify to category field. Find the "MySQL Column Type" field under "Advanced Options". It should be Auto by default. Change it to be "INT" should solve your problem.

Let me know if this works!

Leo - PHP Programmer (in training)
interactivetools.com

By rez - February 15, 2018

Unfortunately, still not working.