We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36613
    • 328 Posts
    I want sort a list of resource for a template variabiles and for publishedon. I try this solution:
    [[getResources?
    &parents=`[[*id]]`
    &tpl=`childItemRow`
    &depth=`0`
    &limit=`400`
    &includeTVs=`1`
    &includeTVList=`image` 
    &includeContent=`1`
    &sortby=`{"publishedon":"ASC","menuindex":"ASC"}`
    &sortbyTV=`mytvfield` 
    &sortdirTV=`DESC`
    ]]


    But doesn't work. The snippets take only order of mytvfield, but not the publishedon order.

    This question has been answered by cristianb88. See the first response.

      • 10208 ☆ A M B ☆
      • 1,780 Posts
      I think you can either sortByTV, or sortBy. But not both. It appears the last sort parameter is what it's using (sortByTV). Could be wrong of course.

        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 10208 ☆ A M B ☆
        • 1,780 Posts
        publishedon is actually a TV, so perhaps you can string that in the sortByTV?
          Frogabog- MODX Websites in Portland Oregon
          "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
          Having server issues? These guys have MODX Hosting perfected - SkyToaster
          • 3749
          • 24,544 Posts
          If you use the &sortByTV, I think it will always be sorted by the TV first, then by the fields in the &sortby property.

          pdoResources (part of the pdoTools package) will let you include TVs in your &sortby property, so you might try that. With pdoTools, you would need to use &includeTVs, which takes a comma-separated list of TVs to process.

          Unfortunately, I think pdoTools only allows one sort direction, so you might be looking at a custom snippet to do what you want.
            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
            • 4172
            • 5,888 Posts
            I think you can define the sort direction within the json for sortby the same way you do it with getResources.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 36613
              • 328 Posts
              But you should i do this code:

              [[getResources?
              &parents=`[[*id]]`
              &tpl=`childItemRow`
              &depth=`0`
              &limit=`400`
              &includeTVs=`1`
              &includeTVList=`image` 
              &includeContent=`1`
              &sortby=`{"mytvfield":"DESC","publishedon":"ASC","menuindex":"ASC"}`
              ]]


              ?
                • 4172
                • 5,888 Posts
                with pdoResources

                [[pdoResources?
                &parents=`[[*id]]`
                &tpl=`childItemRow`
                &depth=`0`
                &limit=`400`
                &includeTVs=`image,mytvfield`
                &includeContent=`1`
                &sortby=`{"mytvfield":"DESC","publishedon":"ASC","menuindex":"ASC"}`
                ]]
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 3749
                  • 24,544 Posts
                  @Bruno17 - Cool idea. I didn't know pdoResources accepted JSON for the &sortby property, but I see that it does.
                    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
                  • discuss.answer
                    • 36613
                    • 328 Posts
                    With pdoResources doesnt' work this sintacs: [[+publishedon:strtotime:date=`%d.%m.%Y`]]
                    The site output wrong date.