We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25663 MODX Staff
    • 12,272 Posts
    Well there I go ... recopied it all up and THIS TIME actually copied it all up and it seems to be working. Thank you!
      Ryan Thrash, MODX Co-Founder
      Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
      • 15987
      • 786 Posts
      I have updated the initial post with all of the latest fixes in this thread.

      I also added in a new parameter called highlightResult. This parameter if set to 1 will output the links with the necessary extra variables for the reult page highlighting (for the plugin). This allows you to highlight the results on the linked pages without having to show the extract in your search results.

      Let me know if anyone finds any problems. I think this should be the final release for a while.
        • 11975
        • 2,542 Posts
        Hi Kylej,

        is there any particular reason not to include the changes I made to extend search to TVs (even if they are not perfect)

        or should I post these changes as an extra to the snippet ?

        :-)
          Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
          • 25663 MODX Staff
          • 12,272 Posts
          heliotrope,

          I think as long as it will search in text/richtext/textareas it would be a definite inclusion. We’re making some more merges down to trunk today and hopefully putting out an RC ASAP. Where were those changes mentioned again?
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 11975
            • 2,542 Posts
            Hi ryan,

            here is the modified doSearch Function (AjaxSearch.inc.php)


            <?php
            
            function doSearch($searchString,$searchStyle,$useAllWords,$ajaxSearch,$docgrp) {
                if ($ajaxSearch) {
                  $table_prefix = connectForAjax();
                } else {
                  global $modx;
                }
                $search = explode(" ", $searchString);
                if ($ajaxSearch) {
                    $tbl_sc = $table_prefix . "site_content";
                    $tbl_stc = $table_prefix . "site_tmplvar_contentvalues";//helio
                    $tbl_dg = $table_prefix . "document_groups";
                } else {
                    $tbl_sc = $modx->dbConfig['dbase'] . "." . $modx->dbConfig['table_prefix'] . "site_content";
                    $tbl_stc = $modx->dbConfig['dbase'] . "." . $modx->dbConfig['table_prefix'] . "site_tmplvar_contentvalues";//helio
                    $tbl_dg = $modx->dbConfig['dbase'] . "." . $modx->dbConfig['table_prefix'] . "document_groups";
                }
            
                if ($docgrp) {
                	$tbl_sql = " LEFT JOIN $tbl_stc stc ON sc.id = stc.contentid ";//helio
                    $tbl_sql .= " LEFT JOIN $tbl_dg dg ON sc.id = dg.document";
                    $qry_sql = "(ISNULL(dg.document_group) OR dg.document_group IN ($docgrp)) AND ";
                } else {
                   $tbl_sql = " LEFT JOIN $tbl_stc stc ON sc.id = stc.contentid ";//helio
                    $qry_sql = "sc.privateweb = 0 AND ";
                }
            
                if ($searchStyle == 'partial'){
                  $sql = "SELECT DISTINCT sc.id, sc.pagetitle, sc.description, sc.content ";
                  $sql .= "FROM $tbl_sc sc" . $tbl_sql . " WHERE ";
                  if (count($search)>1 && $useAllWords){
                    foreach ($search as $searchTerm){//helio
                      $sql .= "(sc.pagetitle LIKE '%$".$searchString."%' OR sc.description LIKE '%$searchString%' OR sc.content LIKE '%$searchTerm%' OR stc.value LIKE '%$searchTerm%') AND ";
                    //	$sql .= "(sc.pagetitle LIKE '%$".$searchString."%' OR sc.description LIKE '%$searchString%' OR sc.content LIKE '%$searchTerm%') AND ";
                    
                    }
                  } else {
                  	$sql .= "(sc.pagetitle LIKE '%$searchString%' OR sc.description LIKE '%$searchString%' OR sc.content LIKE '%$searchString%' OR stc.value LIKE '%$searchString%') AND ";
                  	//$sql .= "(sc.pagetitle LIKE '%$searchString%' OR sc.description LIKE '%$searchString%' OR sc.content LIKE '%$searchString%') AND ";
                  
                  }
                  $sql .= $qry_sql . "sc.published = 1 AND sc.searchable=1 AND sc.deleted=0;";
                } else {
                  $sql = "SELECT DISTINCT sc.id, sc.pagetitle, sc.description, sc.content ";
                  $sql .= "FROM $tbl_sc" . $tbl_sql . " sc WHERE ";
                  if (count($search)>1 && $useAllWords){
                    foreach ($search as $searchTerm){
                      //$sql .= "MATCH (sc.pagetitle, sc.longtitle, sc.introtext, sc.description, sc.content) AGAINST ('$searchTerm') AND ";
                      $sql .= "MATCH (sc.pagetitle, sc.longtitle, sc.introtext, sc.description, sc.content, stc.value) AGAINST ('$searchTerm') AND ";
                    }
                  } else {
                    //$sql .= "MATCH (sc.pagetitle, sc.longtitle, sc.introtext, sc.description, sc.content) AGAINST ('$searchString') AND ";
                  	$sql .= "MATCH (sc.pagetitle, sc.longtitle, sc.introtext, sc.description, sc.content, stc.value) AGAINST ('$searchString') AND ";
                  
                  }
                  $sql .= $qry_sql . "sc.published = 1 AND sc.searchable=1 AND sc.deleted=0;";
                }
            
            
                if ($ajaxSearch) {
                    $rs = mysql_query($sql) or die ("Cannot query the database ($sql)");
                } else {
                    $rs = $modx->dbQuery($sql);
                }
                return $rs;
            }
            
            
              Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
              • 25663 MODX Staff
              • 12,272 Posts
              heliotrope... just tested it out and works great on rich text/ textareas/text which I consider a major improvement. Great work!

              Committing to 095dev pending a merge to trunk soon smiley
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 15987
                • 786 Posts
                heliotrope, sorry, I forgot that you had done that. I will get it added asap.

                Thanks,
                Kyle
                  • 11975
                  • 2,542 Posts
                  Glad to help.

                  But it’s a detail compared to your work kylej

                  :-)
                    Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
                    • 15987
                    • 786 Posts
                    Ok, I have added in the changes from HelioTrope and have updated the initial post with the latest changes. Let me know if all looks good.
                      • 25663 MODX Staff
                      • 12,272 Posts
                      Perfect and with that I think the next release demo content is pretty much up to date. laugh
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me