We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40098
    • 9 Posts
    Hi,
    I'm storing about 100 people as separate resources, each with their own bio[*content], photograph[TV] and I'm using the pagetitle field to store their names (e.g. firstname surname). The client has just asked for the names to sort A->Z by surname (still displaying the same way).

    I've Google'd and not really found anything. I found something similar but that was over a year and a half old and wasn't answered. I'm just wondering if such a task is possible without having to introduce separate template variables for surname?
    I'm using version 1.4.2 of getResources with this sort paramater
    &sortby=`{"pagetitle":"ASC"}`

    Any help of the matter would be awesome!
    Thanks,
    Kingsley
      • 40098
      • 9 Posts
      I've just found this little snippet which orders by the last word in a field order by substring_index(pagetitle, ' ', -1);

      Select * from modx_site_content where parent = 265 order by substring_index(pagetitle, ' ', -1);


      Would be nice if this could be implemented into the getResources plugin!
        • 3749
        • 24,544 Posts
        How about using the introtext or description field for just the last name? That would be a lot faster.

        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          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