We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5811
    • 1,717 Posts
    Regarding the new possibilities about the forms and the filtering with the next release of ajaxSearch (1.9.0) find some new demos on this page.

    • That’s looking awesome coroico ... kudos!
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 5811
        • 1,717 Posts
        Thanks Ryan.

        I just added 2 news demos. Live filtering by Category. These two demos use the two new paging types: "Previous/next" and "Show More N results".

        Edit: you could also simply search * for displaying all the documents.
          • 15076
          • 43 Posts
          The demo’s are looking awesome!

          However, on the example with input6, you link to template input3, small mistake on your side I think shocked theres not much difference between the templates, only a SelectTv call on a quick look, but still its the wrong template wink

          and can you post a link to the snippet SelectTv?

          thanks in advance
          • That is really impressive!
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 5811
              • 1,717 Posts
              Thanks for your encouragements.

              on the example with input6, you link to template input3, small mistake on your side I think
              Yes the txt files are not totally in line with template html files. I will correct this.

              Find below the selectTv (renamed AsSelectTv). This snippet like the snippet radioButton or inputText will be provided with AjaxSearch 1.9.0 in the toolbox. SelectTv get from the database the values of a TV to set up the appropriate option list for the <select></select>. All the parameters are explained in the header of file. &filter allows to filter some values, &first allow to add a first non-database value.

              I use this snippet, to update the selected value when I display the results on the same page as the form. Like on the demo site (I economize the number of pages smiley ) If you display the resuls on a landing page, this snippet is useless and you could write your <select></select> tag as you want.

              <?php
              /* -----------------------------------------------------------------------------
              * Snippet: AsSelectTv
              * ------------------------------------------------------------------------------
              *
              * @author       Coroico - www.modx.wangba.fr
              * @version      1.0.0
              * @date         04/04/2010
              *
              * Purpose:
              *    output the values of a tv as a select tag with options 
              *
              *   tplName : name of the template
              *   tvName :  name of the tv
              *   filter :  a comma separated list of values to exclude from the select
              *   first :   a string value to add in first position in the select
              *   class :   a class to style the select tag
              *
              *   output :  a <select></select> tag
              *
              * e.g: [[AsSelectTv? &tvName=`articleCategory` &tplName=`wgbArticle` &filter=`Architecture` &first=`` &class=`select1`]]
              *
              */
              
              // =============================================================================
              
              if (!class_exists('AsSelectTv')) {
              
                  class AsSelectTv {
              
                      function AsSelectTv() {
                      }
              
                      function display($name, $tplName, $tvName, $filter, $first, $valueSelected, $class) {
                      
                          $valuesTv = $this->getValuesTv($tplName,$tvName); // get the values from the tv
              
                          $filtered = explode(',',$filter);
                          $valuesTv = array_diff($valuesTv, $filtered);   // filter the list of tvs
                          sort($valuesTv);                                // sort the array
                          
                          $class = ($class) ? 'class="' . $class . '"' : '';
                          $output = '<select name="' . $name . '" ' . $class . '>';
                          
                          if ($first != 'no first') {   // add a first item
                              $selected = ($valueSelected == $first) ? "selected" : "";
                              $output .= '<option ' . $selected . '>' . $first . '</option>'. "\n\r";
                          }
                          
                          foreach($valuesTv as $tv) {
                              $selected = ($valueSelected == $tv) ? "selected" : "";
                              $output .= '<option ' . $selected . '>' . $tv . '</option>'. "\n\r";
                          }
                          
                          $output .= '</select>';
                          return $output;
                      }
                      
                      /*!
                      *  getValuesTv : return an array of all distinct values of a tv
                      */
                      function getValuesTv($tplName, $tvName) {
                          global $modx;
                          $valuesTv = array();
              
                          $sql  = "SELECT DISTINCT tvc.value AS name ";
                          $sql .= "FROM " . $modx->getFullTableName('site_templates') . " st , " . $modx->getFullTableName('site_tmplvars'). " tv ";
                          $sql .= "INNER JOIN " . $modx->getFullTableName('site_tmplvar_templates')." tvtpl ON tvtpl.tmplvarid = tv.id ";
                          $sql .= "INNER JOIN " . $modx->getFullTableName('site_tmplvar_contentvalues')." tvc ON tvc.tmplvarid=tv.id ";
                          $sql .= "WHERE st.templatename = '" . $tplName . "' AND tv.name = '" . $tvName . "' ";
                          $sql .= "ORDER by tvc.value";
                          
                          $rs= $modx->db->query($sql);
              
                          while($row = $modx->db->getRow($rs)) {
                              $tvs = explode(',',$row['name']);
                              $tvs = array_map("trim", $tvs);           // trim each value
                              $valuesTv = array_merge($valuesTv, $tvs);
                          }
                          $valuesTv = array_unique($valuesTv);
                          return $valuesTv;
                      }
                  }
              }
              
              // =============================================================================
              
              if (!isset($name)) {
                  echo "<h2>a name should be specified for the select !</h2>";
                  return;
              }
              if (!isset($tvName)) {
                  echo "<h2>a tv name should be specified !</h2>";
                  return;
              }
              if (!isset($tplName)) {
                  echo "<h2>a template name should be specified !</h2>";
                  return;
              }
              
              $first = isset($first) ? $first : 'no first';
              $class = isset($class) ? $class : '';
              
              if (isset($_POST[$name]) && ($_POST[$name])) $valueSelected = $_POST[$name];
              else if (isset($_GET[$name]) && ($_GET[$name])) $valueSelected = $_GET[$name];
              else $valueSelected = '';
              
              $stv = new AsSelectTv();
              $output = $stv->display($name, $tplName, $tvName, $filter, $first, $valueSelected, $class);
              echo $output;
              
              ?>
                • 5811
                • 1,717 Posts
                The ajaxSearch 1.9.0 RC2 is now available on this page.

                Since the RC1, the &withTvs and &tvPhx parameters have been improved and the log features debugged. The ajaxSearch 1.9.0 cheasheet v3.0 is in line with this RC2 release.

                Thanks for your feebacks. The next release will be the final release.
                  • 32396
                  • 56 Posts
                  Hi I’m trying to make the search form like this one: http://www.modx2.wangba.fr/index.php?id=267 (Real Estate)

                  can somebody explain how can it be done? On the demo site only template names are indicated and no example of form ...
                    Using: MODx Evo 1.0.6 / Revo 2.2.5
                    • 30912
                    • 463 Posts
                    Hi coroico, great work.

                    I sent you an email through your site, no idea if you got it - anyway

                    I dont understand what the template is for the AsSelectTv, could you post an example of the teamplte to go with the snippet?

                    Thanks
                      • 5811
                      • 1,717 Posts
                      @Tyreal2012
                      I sent you an email through your site, no idea if you got it
                      Yes, I got it. I will answer you.

                      I dont understand what the template is for the AsSelectTv, could you post an example of the teamplte to go with the snippet?
                      The AsSelectTV is a snippet used to update the page with the data selected thru a list box. It is usefull only when the results are on the same page as the form. If you use a landing page for the results, the use of this snippet is useless.


                      @Wildstriker
                      On the demo site only template names are indicated and no example of form ...
                      As explain on this page, customization mechanisms are not explained/provided for free with the ajaxSearch snippet.
                      You have the choice to donate for the ajaxSearch development or to buy the customization solution.

                      The customization is based on a configuration file. I provide you the way to do the appropriate search & filter, what ever your form. If you are a developer, this is a reusable solution that you can adapt to your needs for all your projects. These developments don’t require to hack the AjaxSearch code.