We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40088
    • 708 Posts
    Revo 2.3.2
    SimpleSearch 1.9

    I understand how to set SS to only search a specific parent resource (id). Easy. But I have a bunch of nested categories/resources and I would rather not hard-code SS for each specific area.

    Instead, what I would like to do on the front-end is keep the default site-wide search then provide a picker that lists all the main categories of the site. So for example, if the visitor is on the homepage and they decide they only want to search the Category 8 resource they can select it from the picker which in turn would dynamically change the value that controls the location of the search.

    Is that (or something similar) possible?

    This question has been answered by Bruno17. See the first response.

      Todd
      • 4172
      • 5,888 Posts
      you can add a listbox with name 'parent' witch lists all containers, to the search-form.
      Could be generated with getResources, for example.

      Install getReqParam

      At the landing-page have

      &ids=`[[!getReqParam? &name=`parent`]]`
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 40088
        • 708 Posts
        Thanks Bruno17. I'm not sure about the specifics of your suggestion, though. For example, does Install getReqParam go in a getResources call in the SS form? [ed. note: todd.b last edited this post 11 years, 10 months ago.]
          Todd
          • 3749
          • 24,544 Posts
          This is somewhat similar: http://wordsmatter.softville.com/quotes.html.

          It's just a form that "posts" the user's responses to another page where the search is performed and the results displayed on the basis of the form entries. There are only two resources involved. The one with the form and the one containing the snippet that shows the results.

            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
            • 40088
            • 708 Posts
            Thanks Bob, I bookmarked it.

            It seems like Bruno's suggestion is very much along the lines of what I'm after, I just need more of an explanation about Install getReqParam and the listbox settings.
              Todd
              • 42046
              • 436 Posts
              Quote from: todd.b at Nov 08, 2014, 11:17 PM
              I just need more of an explanation about Install getReqParam and the listbox settings.

              He means install the extra getReqParam http://modx.com/extras/package/getreqparam (or you could use getURLparam) and use a standard html form or link to sent a parameter via the url to the search landing page, then use Bruno's code to pass the parameter to the SimpleSearch call.
                • 40088
                • 708 Posts
                Thanks, I made some progress. I have a listbox with available search categories. But even if I select a specific category the results are from the entire site.

                Search Form
                <form class="sisea-search-form" action="[[~[[+landing:default=`[[*id]]`]]]]" method="[[+method:default=`get`]]">
                  <fieldset>
                     <select name="parent" id="parent">
                        <option value="0">Search entire site</option>
                        <option value="2">Cat. 1</option>
                        <option value="19">Cat. 2</option>
                        <option value="5">Cat. 3</option>
                    </select>
                    <label for="[[+searchIndex]]">[[%sisea.search? &namespace=`sisea` &topic=`default`]]</label>
                    <input type="text" name="[[+searchIndex]]" id="[[+searchIndex]]" value="[[+searchValue]]" placeholder="Search">
                    <input type="hidden" name="id" value="[[+landing:default=[[*id]]]]">
                    <input type="submit" value="[[%sisea.search? &namespace=`sisea` &topic=`default`]]" />
                  </fieldset>
                </form>

                Results Landing Page
                [[!getResources?
                    &ids=`[[!getReqParam? &name=`parent`]]`
                ]]

                SimpleSearch Call
                [[!SimpleSearchForm?
                	&tpl=`Search Form`
                	&landing=`17`
                	&ids=`[[getReqParam? &name=`parent`]]`
                ]]
                [ed. note: todd.b last edited this post 11 years, 10 months ago.]
                  Todd
                • discuss.answer
                  • 4172
                  • 5,888 Posts
                  at the landing-page you will need something like:

                  [[!SimpleSearch?
                      &ids=`[[!getReqParam? &name=`parent`]]`
                  ]]


                  not sure, what you are doing with the getResources-call and with the getReqParam in the SimpleSearchForm - call.

                  The getResources-call was meant to build the options in your search-form.
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 40088
                    • 708 Posts
                    Thanks Bruno, that fixed it. The other stuff is leftover from another tutorial.

                    Out of curiosity is it possible to use a TV to generate the select element in the search form?

                    <select name="parent" id="parent">
                            <option value="0">Search entire site</option>
                            <option value="2">Cat. 1</option>
                            <option value="19">Cat. 2</option>
                            <option value="5">Cat. 3</option>
                    </select>
                    
                      Todd
                      • 4172
                      • 5,888 Posts
                      as allready said, you can use getResources to build them

                      <select name="parent" id="parent">
                      <option value="0">Search entire site</option>
                      [[!getResources? 
                          &parents=`0`
                          &tpl=`tplSearchOption`
                      ]]
                      </select>


                      chunk tplSearchOption:
                      <option [[!getReqParam:is=`[[+id]]`:then=`selected="selected"`:else=``? &name=`parent`]] value="[[+id]]">[[+pagetitle]]</option>


                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!