We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32396
    • 56 Posts
    @coroico
    Thanks for answer I’ll take into regard. I didn’t noticed because sometimes I read by diagonal smiley I was in a hurry with this project and made it with tvExplorer but in the future I’ll probably apply to you for the issue.

      Using: MODx Evo 1.0.6 / Revo 2.2.5
      • 37210
      • 131 Posts
      Hi Coroico and forum,

      I have attached a screenshot of what I am trying to achieve.

      Is there a simple way to add options which modify the order/number of results? I have looked through the options on the wangba website but none of them deal with the sort order.

      Thanks for your help!
      Sarah
        • 5811
        • 1,717 Posts
        @Sarah

        Is there a simple way to add options which modify the order/number of results?

        relevance => rank parameter
        order => order parameter
        limit => grabMax or ajaxMax (depending the ajaxSearch mode using)

        Unfortunately these paremeters can’t be initialized from a $_GET or $_POST variables. So you can’t change it throught a form.

        To run this form requires a specific development (without change of AjaxSearch)
          • 5811
          • 1,717 Posts
          @Sarah

          To run this form requires a specific development (without change of AjaxSearch)
          as a gift ... but not tested wink

          Set up a snippet called for instance NewSearch:
          <?php
          // snippet used to wrap a specific call to AjaxSearch
          
          $aslmt = isset($_POST['aslmt']) ? strip_tags($_POST['aslmt']) : 10;
          $asrel = isset($_POST['asrel']) ? strip_tags($_POST['asrel']) : "order";
          
          // init relevance
          $relevance = ($asrel == 'order') ? '' : 'pagetitle:100,content';
          
          // runs only with the non-ajax mode.
          $params = array (
              'ajaxSearch' => 0, 
              'showInputForm' => 0,
              'grabMax' => $aslmt,
              'order' => 'publishedon DESC',
              'rank' => $relevance
          );
          
          return $modx->runSnippet('AjaxSearch', $params);
          ?>


          Set up your form as below (not tested too!) - replace id=157 by the landing page id you want
          <form id="ajaxSearch_form" action="index.php?id=157" method="post">
              <fieldset>
                  <label>
                    <input id="ajaxSearch_input" class="cleardefault" name="search" value="Search here..." onfocus="this.value=(this.value=='Search here...')? '' : this.value ;" type="text">
                  </label>
                  <label>
                      <input id="ajaxSearch_submit" name="sub" value="Go!" type="submit">
                  </label>
                  <br><br>
                  <div>
                      <input name="asrel" value="rank" checked="checked" type="radio"><label for="rank">Sort by relevance</label>
                      <input name="asrel" value="order" type="radio"><label for="frdoc">Sort by date last modified</label>
                      <label>
                          <select name="aslmt">
                              <option>5</option>
                              <option selected="selected">10</option>
                              <option>20</option>
                              <option>50</option>
                          </select>
                          Number of results per page
                      </label>
                  </div>
              </fieldset>
          </form>

          Then on your landing page (Here #157) adds [!NewSearch? &param1=`value1` &param2=`value2`!] where param1, param2, ... are classical ajaxSearch parameters. Don’t use &rank, &order or &grabMax to avoid a conflict with your NewSearch parameters.[EDIT] After much thought, you can’t pass the parameters like this. You need to use the $params array.

            • 37210
            • 131 Posts
            Hi coroico..

            o.O i like this gift...


            :) Thanks for this! Unfortunately it looks like the server is down so I can’t test this out until tomorrow. Bleh. But until then, this looks like the perfect solution.

            Thanks heaps.
            Sar

              • 5811
              • 1,717 Posts
              @sarah
              In the end the code posted previously can’t run totally. AjaxSearch should be customized.

              I have set up a new demo with your request: Choose the relevance of results

              Send me an email to get the custom code. AjaxSearch snippet code remains inchanged.
                • 37210
                • 131 Posts
                Hi coroico..

                I have sent you an email on your Wangba site. I wasn’t quite sure how else to get in touch with you!

                Hope to hear from you soon.

                Sarah
                  • 5811
                  • 1,717 Posts
                  @sarah. I got your email and sent you the custom code.
                    • 37210
                    • 131 Posts
                    Thanks! Got it.
                      • 37210
                      • 131 Posts
                      Thanks so much for that Coroico.

                      You guys pretty much did all of the work for me! Honestly I think it would have taken us a whole week to figure it out and you replied so quickly with the solution. I didn’t even have to change the template you sent us smiley

                      If I was in charge of the invoicing for this project, I would, without hesitation, donate a whole wad of cash. I am hoping that we donate to MODx and snippet/plugin developers the next client website we do. Because, seriously, how much time and effort has MODx and affiliates saved us? While asking for nothing in return? Developers need monies too!

                      Sarah