We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Hello,

    The scenario is as follows:

    3 Search Fields

    • Search by: Business Name (tied to [[$pagetitle]]
    • Search by: Category (using TagLister to create categories and to create a select list for the search form with all the categories in a particular Template Variable)
    • Search by: Property (also TagLister with a different TV of course)

    If more than one field is populated, then all the conditions must be true. For example if the Property is "The Big Building" and the Category is "PHP Programmer" then both must be true to produce a result.

    TagLister is a perfect tool for categories and in this case properties but what is the best Search snippet to use?

    • You could use SimpleSearch and use hooks to do additional searching, or use AdvSearch which is more aimed at custom searches (tho I don't have first hand experience with it, sorry). Both of them are available via package manager and documented at the RTFM.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
      • We actually went with a much simpler approach because this search is limited to documents all within a specific parent document. We created a standard search form and passed the variables onto a search results pages with a getPage/getResources call on it. For the filtering, we used the tvFilters parameter in combination with getUrlParam:

        [[!getPage@Directory?
        &elementClass=`modSnippet`
        &element=`getResources`
        &parents=`132`
        &limit=`10`
        &pageVarKey=`page`
        &includeTVs=`1`
        &includeContent=`1`
        &tvPrefix=``
        &tvFilters=`busname==%[[!getUrlParam? &name=`bname` &max=`999`]]%,directorycategories==%[[!getUrlParam? &name=`category` &max=`999`]]%,directoryproperties==%[[!getUrlParam? &name=`properties` &max=`999`]]%`
        &tpl=`directorymemberTPL`
        ]]

        A user can input one or a combination of search fields and it works wonderfully.
          • 44148
          • 1 Posts
          I am trying to do it like rx2 above but having issue with getUrlParam not returning value when inside getPage snippet call (or is it an issue w/ getResources ?).

          Weird because I swear rx2's snippet works when used with a raw value supplied in tvFilters and I have verified my getUrlParam returned correct value when used in isolation.

          My snippet call

          [[!getPage@Directory?
          &elementClass=`modSnippet`
          &element=`getResources`
          &parents=`8,9` &depth=`2`
          &limit=`10` &tvPrefix=``
          &pageVarKey=`page`
          &includeTVs=`1`
          &includeContent=`1`
          &tvFilters=`locationTV==[[!getUrlParam? &name=`location` &max=`999`]]` &tpl=`eachListingTpl`
          ]]

          Any input would be appreciated, thanks.
            You want something. Go Get it. Period.