We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8822
    • 203 Posts
    Does anyone know if it is possible to sort search results (using SimpleSearch) by TV values? If so, what is the syntax. I have used the properties &sortBy and &sortbyTV with getResources and pdo, but SimpleSearch does not appear to support &sortbyTV. What is the best way of doing this?
      • 36613
      • 328 Posts
      Try this:

      [[!getPage?
         &elementClass=`modSnippet`
         &element=`SimpleSearch`
       
         &parents=`17`
         &depth=`2`
         &limit=`10`
         &pageVarKey=`page`
       
         &includeTVs=`1`
         &includeContent=`1`
      
         &sortby=`{"publishedon":"ASC","createdon":"DESC"}`
         &tpl=`yourResultsTpl`
      ]]
      
        • 8822
        • 203 Posts
        Thanks for that, i use the same syntax for the &sortby for pdoResources, but this does not appear to work for SimpleSearch (unless i have mis typed something). My code is given below - starrating and listingtype are Template Variables

        [[!getPage?
           &elementClass=`modSnippet`
           &element=`SimpleSearch`
          
           &parents=`3`
           &depth=`2`
           &limit=`10`
           &pageVarKey=`page`
          
           &includeTVs=`1`
           &includeContent=`1`
         
           &sortby=`{"starrating":"DESC", "listingtype":"DESC", "latestrecdate":"ASC"}`
           &tpl=`fbnsearchresultstpl`
        ]]


        Any ideas what i am doing wrong?
          • 36613
          • 328 Posts
          Quote from: Emily at Sep 30, 2013, 02:21 PM
          Thanks for that, i use the same syntax for the &sortby for pdoResources, but this does not appear to work for SimpleSearch (unless i have mis typed something). My code is given below - starrating and listingtype are Template Variables

          [[!getPage?
             &elementClass=`modSnippet`
             &element=`SimpleSearch`
            
             &parents=`3`
             &depth=`2`
             &limit=`10`
             &pageVarKey=`page`
            
             &includeTVs=`1`
             &includeContent=`1`
           
             &sortby=`{"starrating":"DESC", "listingtype":"DESC", "latestrecdate":"ASC"}`
             &tpl=`fbnsearchresultstpl`
          ]]


          Any ideas what i am doing wrong?

          I found this discussion:
          https://forums.modx.com/thread/?thread=47809&page=1

          try and tell me
            • 8822
            • 203 Posts
            Hi there, thanks. Not sure that really covers what i am looking for though - my issue is purely with being able to sort the search results by TVs - i am not sure that this is possible?