We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3743
    • 42 Posts
    i’ve searched through the docs and found out that wf can sort only by some fields. any hacks/ideas on how to sort by a custom tv? Thanks in advance.
      • 7455
      • 2,204 Posts
      I would also like the option to use a tv as link text that would be a nice addition to wayfinder to make it even more flexible.
        follow me on twitter: @dimmy01
        • 20343
        • 3 Posts
        I’m trying to find out if there has been any change to this. Is it possible to use a template variable in the &sortBy parameter within the Wayfinder call? Would be very useful, since lists of database items could be re-sorted by many more things that are actual item attributes, not just the limited list of document values.

        Please post if anyone knows!! Thanks a lot.
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: mpjtone at Mar 06, 2010, 03:37 PM

          I’m trying to find out if there has been any change to this. Is it possible to use a template variable in the &sortBy parameter within the Wayfinder call? Would be very useful, since lists of database items could be re-sorted by many more things that are actual item attributes, not just the limited list of document values.
          You can write a custom snippet/query to do this and return what you need, though sorting on a TV value is going to be much slower that sorting on predefined Resource attributes because of the nature of Template Variables. This is even worse if you have some kind of dynamic information stored as your Template Variable values (e.g. @INHERIT, etc.) because then you have to process each and every TV value after retrieving it from the database before you can sort.

          Let me just say that using MODx Resources to represent "database items" is really a shortcut, and not at all the best way to approach developing custom sites in MODx, especially with any significant quantities involved. IMO, data that needs to be custom sorted by user-defined attributes spells custom data model. This is the difference between developing a presentation layer of unique "views" (what MODx is for) and a "model" layer (for accessing/managing custom data that is not well represented by having each row be a MODx Resource, i.e. web page). This makes your custom data reusable in an infinite variety of presentation views, your dynamic presentation layer much lighter, and your ability to sort your data on demand efficiently much improved.
            • 20343
            • 3 Posts
            Thanks Jason, this makes sense that sorting by TVs would be slow, and I also appreciate your comment about using ModX resources as database items. I had been thinking of building an ecommerce site this way and I imagine that this would be an issue if the catalog has a significant number of products/items. Maybe for limited product counts it would be ok, but it wouldn’t scale.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              This has been done several times before, and one of the things it always runs aground on is that basic limitation of the number of items. It’s OK, as you say, for a small shop with few items, but for anything serious you really need a whole new database structure.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org