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

    I’ve imported a site from EVO to REVO and i’m migrating Ditto to GetResources.

    Snippets works fine, but I need to sort by TV from this values: 10, 9.5, 9, 8.5, etc.

    Using DITTO: &orderBy=`numbers DESC` (this paremeters works fine)

    Using GetResources: &sortbyTV=`numbers` &sortdirTV =`DESC` (9.5, 9, 8.5, 10) Number 10 is in the end of the list.

    What should I do? (Sorry for my english)
    Cheers
      • 5340
      • 1,624 Posts
      try


      &sortbyTV=`ABS(numbers)`

      OR

      &sortbyTV=`CONVERT(INT,numbers)`

      OR

      &sortbyTV=`numbers+0`


      I haven’t tested any of the above. Hopefully get resources likes the syntax
      Please post back
        • 17384
        • 24 Posts
        Thanks for the help, but it still doesn’t work.

        I’ve tried even with: &sortdir=`DESC` but doesn’t work either.

        Any other sugestions?

        Thanks.
          • 3749
          • 24,544 Posts
          I’m not sure it will help, but make sure you have &includeTVs=`1` and &tvPrefix=`` (and maybe &processTVs=`1`) in the tag.
            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
            • 17384
            • 24 Posts
            BobRay:

            Thank for the help, but is doesn’ work. &includeTVs=`1`, &tvPrefix=`tv.` and &processTVs=`1` are included.

            Any other sugestions? It seems that GetResources "see" the number 10 as 1, or "see" numbre 9.5 as 95.

            cheers.
              • 53879
              • 7 Posts
              I have this same problem. Has anyone come up with a solution?
                • 3749
                • 24,544 Posts
                Try adding this to the getResources tag:

                &sortbyTVType=`decimal`
                  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
                  • 53879
                  • 7 Posts
                  Thanks for the quick reply. My issue is sorting products by cost and the numbers are between 10 - 2000. sortbyTVType by decimal or integer doesn't work and lumps a $1000 product between 90 & 298.

                  Quote from: BobRay at Dec 18, 2018, 07:55 PM
                  Try adding this to the getResources tag:

                  &sortbyTVType=`decimal`
                    • 3749
                    • 24,544 Posts
                    I really thought that would do it:

                    case 'decimal':
                         $criteria->select("CAST(IFNULL(tvSort.value, tvDefault.default_text) AS DECIMAL) AS sortTV");
                         break;


                    Does your TV value begin with a dollar sign? That could interfere with the sorting process.
                      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
                      • 53879
                      • 7 Posts
                      Quote from: BobRay at Dec 19, 2018, 03:36 AM
                      I really thought that would do it:

                      case 'decimal':
                           $criteria->select("CAST(IFNULL(tvSort.value, tvDefault.default_text) AS DECIMAL) AS sortTV");
                           break;


                      Does your TV value begin with a dollar sign? That could interfere with the sorting process.

                      No, it does not start with the dollar sign. This snippet did the trick. Thank you! [ed. note: recordingclub last edited this post 5 years, 3 months ago.]