We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26584
    • 4 Posts
    Really just this quick question here.

    Any ideas?

    &sortBy=`myTemplateVariable`

    is this possible?

    Couldn’t find anything in the docs sad
      • 7231
      • 4,205 Posts
      Not in wayfinder.
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 16183
        • 1,390 Posts
        Maybe if you stated exactly what you want to do there could be other solutions to your problem? Just wondering..

        /k
          • 7231
          • 4,205 Posts
          You can with Ditto. I wayfinder it seems that only document variables are available:

          &sortBy
          default: menuindex
          values: [ id | menutitle | pagetitle | introtext | menuindex | published | hidemenu | parent | isfolder | description | alias | longtitle | type | template | random ]
          description: The sortBy parameter allows the output to be sorted by any of the above fields on a level by level basis. This means that each submenu will be sorted independently of all other submenus at the same level. Random will sort the output differently every time the page is loaded if the snippet is called uncached.

          Have you tried to sort by TV? Sometimes things will work even if they are not documented (and WF does output TVs, so you never know, maybe it DOES sor by them as well).
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don't know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 3749
            • 24,544 Posts
            Looking at the code, I don’t think it can work. Wayfinder will only sort by fields in the site_content table plus random (which it handles separately). There’s no TV information at all in the site_content table.

            It looks like you’d have to hack Wayfinder to get the template for each document, then the respective TV names from another table, then the TV contents from yet another table. It could be done but not easily.
              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
              • 22303 MODX Staff
              • 10,725 Posts
              Quote from: BobRay at Sep 19, 2008, 11:57 PM

              It looks like you’d have to hack Wayfinder to get the template for each document, then the respective TV names from another table, then the TV contents from yet another table. It could be done but not easily.
              Or efficiently I might add. TV values being joined into the query wouldn’t be that difficult or add that much time, but since they may have to be processed to get the actual value to sort on, this could potentially be the most inefficient part of your entire site. And being that the navigation is persistent across pages, unless you cache all of your Wayfinder instances on cacheable pages, that could be a serious bottleneck for your site’s performance.

              If you know what TV you want to sort on, it wouldn’t be too difficult to just create your own script to do this. Heck you could even just make a copy of the Wayfinder snippet and simply name it something like WayfinderCustomTVSort and optimize the query to do exactly what you want.
                • 3749
                • 24,544 Posts
                Just a thought. If there’s an unused field (e.g. summary, longtitle, alias, menu index, etc.), you could put your TV value there and then have Wayfinder sort on that field. You could write a plugin that would fill that field from the TV when the document is saved.

                  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
                  • 19328
                  • 433 Posts
                  Sorry for digging up this ancient post. But for any Google-users ending up on this page and wondering how to sort Wayfinder on a template-variable; you can't tongue But now there is pdoTools which does this job! Install pdoTools from the package manager, and use this call:

                  [[pdoMenu?
                  &parents=`1`
                  &level=`1`
                  &sortby=`myTV`
                  &includeTVs=`myTV`
                  ]]


                  RTFM of pdoTools here: http://docs.modx.pro/en/components/pdotools/snippets/pdomenu
                    • 3749
                    • 24,544 Posts
                    Excellent news. Thanks for posting that.
                      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