We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2453
    • 26 Posts
    Hi, I’m trying to find a way to sort getResources in whatever order they appear in the tree menu, as they function for the menu. I want the editor to be able to control which element appears first on the home page, and this seems like the best solution, if possible without too much hassle. Alternatively I could use a tv dropdown/radio that gets the number of elements within a resource and lets the order be chosen that way, but being able to simply re-order would be so nice!

    Any ideas on this? The help page doesn’t mention what can be used for sortby.
      • 2453
      • 26 Posts
      I’m sorry, sometimes it’s in asking the question you come to the answer smiley
      [[!getResources?
        &parents=`3`
        &hideContainers=`1`
        &tpl=`bioSummaryTpl`
        &tplFirst=`bioSummaryFirstTpl`
        &sortby=`menuindex`
        &includeTVs=`1`
        &processTVs=`1`
      ]]
        • 3749
        • 24,544 Posts
        Right. When you drag things around in the tree, the menuindex numbers are rewritten accordingly.

        If you change the tree to sort it on some other field (e.g., pagetitle, createdon, publishedon, it doesn’t change the menuindex numbers *unless you drag something into another position* -- then it does.

        If you always sort by menuindex, you can just design your menu in the tree by clicking and dragging.
          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
          • 2453
          • 26 Posts
          Great, that is good to know. What threw me off at first was that I was expecting the sort order to be ascending by default for some reason, so when the 2nd of my two items was on top, I thought it wasn’t working. Man, I feel like a whole new world of possibilities is opening up now that I’m learning how to use getResources with chunks with placeholders in them.