We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41483
    • 5 Posts
    Hi,

    I have a strange problem with getResources sorting the results. I want to sort them by menuindex. Let's say I have:

    Slide 1 - menuindex: 1
    Slide 2 - menuindex: 2
    Slide 3 - menuindex: 3
    Slide 4 - menuindex: 4
    Slide 5 - menuindex: 5

    It works correctly until I change the order of two slides. Let's say I change it to:

    Slide 1 - menuindex: 1
    Slide 2 - menuindex: 2
    Slide 3 - menuindex: 3
    Slide 4 - menuindex: 5
    Slide 5 - menuindex: 4


    After that Slide 5 seems to appear randomly (sometimes it on 3rd position, sometimes it stays where it was), then I have to unpublish the slide, save it, and then publish it again - then the order is correct.

    Has anyone had a similar problem to mine?

    Cheers,
    Tomasz
      • 37042
      • 384 Posts
      Yes, I had the same issue a few months ago using GetResources. I updated modx and GetResources to the lates versions and it fixed itself. Which version of both are you using?
        ...
        • 41483
        • 5 Posts
        Hi,
        Thanks for the reply.
        I'm using Modx Revo 2.2.4 and I've just updated getResources from 1.4.2 to 1.5.1 but the problem still exists.
          • 37042
          • 384 Posts
          The only thing I can suggest would be to delete and recreate the problematic slides. I had a similar sorting issue in the past and that helped. Just backup your stuff first.
            ...
            • 41483
            • 5 Posts
            Hi,
            Thanks for the tip, I guess that's the only thing I can do right now.

            Cheers,
            Tomasz
              • 3749
              • 24,544 Posts
              Are you changing the menuindex by dragging-and-dropping resources in the tree? That will renumber all the menuindexes and might (or might not) be more reliable.

              Is you're getResources call uncached?

              [[!getResources ... ]]


              (You probably don't want it uncached when you're finished, but you might while you're working).


              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 41483
                • 5 Posts
                Hello,

                I tried both ways: to manually change the order and to change it by drag-and-drop, but in both cases it doesn't work.
                My getResources call is as follows:

                [[!getResources?
                  &parents=`14`
                  &showHidden=`true`
                  &includeTVs=`true`
                  &processTVs=`true`
                  &idx=`1`
                  &tpl=`slider-row`
                  &tplFirst=`slider-row-first`
                  &sortBy=`menuindex`
                  &sortdir=`ASC`
                ]]


                so I take it's uncached.

                By the way Bob, great work on your MODx Guides!

                Thanks,
                Tomasz
                  • 3749
                  • 24,544 Posts
                  Thanks for the kind words. I'm sorry I can't be more help here.

                  You don't have MySQL 5.0.51 by any chance? It has trouble with sorting.


                  ------------------------------------------------------------------------------------------
                  PLEASE, PLEASE specify the version of MODX you are using.
                  MODX info for everyone: http://bobsguides.com/modx.html
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 41483
                    • 5 Posts
                    MySQL version is 5.1.61 so I guess this isn't a problem.
                    For now I did what @eladnova suggested, so the order is the way I wanted it to be. If there's any need of changing it in future I'll just do it myself (change the order - unpublish - save - publish - save) - I can live with that smiley

                    Thank you all for your help.

                    Tomasz
                      • 3749
                      • 24,544 Posts
                      Could you file that as a bug at http://bugs.modx.com?

                      Be sure to list all your environment settings (PHP version, MySQL version, MODX, version, etc.).


                      ------------------------------------------------------------------------------------------
                      PLEASE, PLEASE specify the version of MODX you are using.
                      MODX info for everyone: http://bobsguides.com/modx.html
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting