On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • If I in AjaxSearch search for +next+ or *pagetitle* without brackets [ ] it works!!

    Very Cool! But can I exclude it? I am too stupid for the documentation...  tongue


    Edit: This doesnt happen on my other websites... So I will solve this! smiley


    and upgrade as well.
      @hawproductions | http://mrhaw.com/

      Infograph: MODX Advanced Install in 7 steps:
      http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

      Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
      http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
    • If I in AjaxSearch search for +next+ or *pagetitle* without brackets [ ] it works!!
      Sorry, I am also stupid and I don’t understand the question laugh
      and upgrade as well.
      Which version of AjaxSearch do you use ? 1.8.1 ?
      • -edited-
        I upgraded to latest version of snippet 1.8.1 and highligthing-plugin 1.3 but no matter
        how I call it...

        1. It shows the search result of:  +placeholder+
        2. On the linked page it shows all &nbsp; and hidden content <!---
        3. It higlights the searched placeholder e.g. +next+: &lt; Previous&nbsp;1&nbsp;Next &gt;
        4. I can search the name of chunks, $modx and even !Ajax for finding the landing page.

        With the "Remove Highlighting" link I can get the page showing normal. But this sucks for now.
          @hawproductions | http://mrhaw.com/

          Infograph: MODX Advanced Install in 7 steps:
          http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

          Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
          http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • AjaxSearch use the chunkie class and the phx.parser class to parse the placeholders. Have you any Php error message which could explain why the parser doesn’t run ?
          What I don’t understand too, is that +next+ and +placeholder+ are not ajaxSearch placeholders ! All the AS placeholders are named [+as.something+].

          Could you redo your tests with the debug mode = 3 and check the templates in the ajaxSearch_log.txt file.
          • What I mean is that if I search for this exact phrase: +next+ it finds my blog documents which have that placeholder, but it also finds
            the name of chunks and "$modx" etc.

            I have installed PHx and havent had any problems. I tried disable without any change.

            [8-Nov-08 06:33:13]  AjaxSearch 1.8.1 - Php5.2.6 - MySql 4.1.25-Debian_mt1
            [8-Nov-08 06:33:13]  AjaxSearch - Configuration file default : 
            <?php
            // For a global parameter initialisation use the following syntax $__param = 'value';
            // To overwrite parameter snippet call use $param = 'value';
            
            // StripInput user function. 
            // Uncomment and complete the core function and choose your own function name
            // string functionName(string searchstring)
            // functionName : name of stripInput function passed as &stripInput parameter
            // searchstring : string php variable name as searchString input value
            // advSearch : string advSearch variable as advSearch parameter and return value
            // return the filtered searchString value
            /*
            function myStripInput($searchString, &$advSearch){
              $advSearch = 'exactphrase';
              return $searchString;
            }
            */
            // StripOutput user function
            // Uncomment and complete the core function and choose your own function name
            // string functionName(string results)
            // functionName : name of stripOutput function passed as &stripOutput parameter
            // results : string php variable name as results
            // return the filtered results
            /*
            function myStripOutput($results){ 
            
              return $results;
            }
            */
            // searchWordList user function
            // Uncomment and complete the core function and choose your own function name
            // string functionName()
            // functionName : name of searchWordList function passed as &searchWordList parameter
            // return a comma separated list of words
            /*function searchWordList($params){ 
            
              switch($params[0]){ 
                case '61':
                  $list = "primary,school,education,children,teacher,africa,litteracy,bicycle";
                  break;         
                case '62':
                  $list = "primaire,école,éducation,enfants,professeur,afrique,littérature,bicyclette";
                  break; 
              }
              return $list;
            }
            */
            ?>
            [8-Nov-08 06:33:13]  AjaxSearch - User configuration - Before parameter checking : Array
            (
                [config] => default
                [version] => 1.8.1
                [debug] => 3
                [language] => english
                [ajaxSearch] => 0
                [advSearch] => oneword
                [whereSearch] => content|tv
                [subSearch] => 5,1
                [withTvs] => 
                [order] => publishedon,pagetitle
                [rank] => pagetitle:100,extract
                [minChars] => 3
                [AS_showForm] => 1
                [resultsPage] => 0
                [grabMax] => 10
                [extract] => 1:content,description,introtext,tv_content
                [extractLength] => 200
                [extractEllips] => ...
                [extractSeparator] => <br />
                [formatDate] => d/m/y : H:i:s
                [highlightResult] => 1
                [pageLinkSeparator] =>  | 
                [AS_landing] => 8
                [AS_showResults] => 1
                [idType] => parents
                [parents] => 
                [documents] => 
                [depth] => 10
                [hideMenu] => 2
                [hideLink] => 1
                [filter] => 
                [tplLayout] => @FILE:assets/snippets/ajaxSearch/templates/layout.tpl.html
                [tplResults] => @FILE:assets/snippets/ajaxSearch/templates/results.tpl.html
                [tplResult] => @FILE:assets/snippets/ajaxSearch/templates/result.tpl.html
                [tplPaging] => @FILE:assets/snippets/ajaxSearch/templates/paging.tpl.html
                [stripInput] => defaultStripInput
                [stripOutput] => defaultStripOutput
                [searchWordList] => 
                [breadcrumbs] => 0
                [tvPhx] => 0
                [clearDefault] => 0
                [jsClearDefault] => assets/snippets/ajaxSearch/js/clearDefault.js
            )
            
            [8-Nov-08 06:33:13]  AjaxSearch - tplResult template @FILE:assets/snippets/ajaxSearch/templates/result.tpl.html : <div class="[+as.resultClass+]">
              <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.longtitle+]">[+as.pagetitle+]</a>
            [+as.descriptionShow:is=`1`:then=`
              <span class="[+as.descriptionClass+]">[+as.description+]</span>
            `+]
            [+as.extractShow:is=`1`:then=`
              <div class="[+as.extractClass+]"><p>[+as.extract+]</p></div>
            `+]
            [+as.breadcrumbsShow:is=`1`:then=`
              <span class="[+as.breadcrumbsClass+]">[+as.breadcrumbs+]</span>
            `+]
            </div>
            [8-Nov-08 06:33:13]  AjaxSearch - tplResults template@FILE:assets/snippets/ajaxSearch/templates/results.tpl.html : [+as.noResults:is=`1`:then=`
              <div class="[+as.noResultClass+]">
                [+as.noResultText+]
              </div>
            `:else=`
              <p class="ajaxSearch_resultsInfo">[+as.resultInfoText+]</p>
              [+as.paging+]
              [+as.listResults+]
              [+as.paging+]
            `+]
            [8-Nov-08 06:33:13]  AjaxSearch - tplResult template@FILE:assets/snippets/ajaxSearch/templates/layout.tpl.html : [+as.showForm:is=`1`:then=`
            <form [+as.formId+] action="[+as.formAction+]" method="post">
                <fieldset class="form3">
            		<input type="hidden" name="advSearch" value="[+as.advSearch+]" />
                <label for="ajaxSearch_input">
                  <input id="ajaxSearch_input" class="cleardefault" type="text" name="search" value="[+as.inputValue+]"[+as.inputOptions+] />
                </label>
                <label for="ajaxSearch_submit">
                  <input id="ajaxSearch_submit" type="submit" name="sub" class="button" value="" />
                </label>
                </fieldset>
            </form>
            `+]
            [+as.showIntro:is=`1`:then=`
            <p class="ajaxSearch_intro" id="ajaxSearch_intro">[+as.introMessage+]</p>
            `+]
            [+as.showResults:is=`1`:then=`
            [+as.results+]
            `+]
            
              @hawproductions | http://mrhaw.com/

              Infograph: MODX Advanced Install in 7 steps:
              http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

              Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
              http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
            • If I in AjaxSearch search for +next+ or *pagetitle* without brackets [ ] it works!!

              Very Cool! But can I exclude it?
              The default stripInputFunction excludes all the modx tags like [+something+] but if you would like exclude also +something+ you need to define and improve your own stripInput function.
              For that adds in your AS configuration file some like that :
                function mrhawStripInput($searchString){
              
                  if ($searchString !== ''){  
                    // Remove escape characters
                    $searchString = stripslashes($searchString);
              
                    // Remove modx sensitive tags
                    $searchString = stripTags($searchString);
              
                    // Remove +something+ substring too
                    $searchString = stripOtherTags($searchString);  
              
                    // Strip HTML tags
                    $searchString = stripHtml($searchString);  
                  }  
                  return $searchString;
                }
              
              function stripOtherTags($text){
                // Regular expressions to remove +something+
                $modRegExArray[] = '~\+(.*?)\+~';   // +phx+
              
                // Remove modx sensitive tags
                foreach ($modRegExArray as $mReg)$text = preg_replace($mReg,'',$text);
                return $text;
              }
              and adds &stripInput=`mrhawStripInput` in your snippet call and if you define a new configuration don’t forget to add &config=`yourConfig` otherwise modify the default config file.
              • Thank you so much!  smiley

                I just placed your code in the bottom of default.config.php (where everything was commented out)

                That gave me: Fatal error: Cannot redeclare mrhawstripinput() (previously declared in .../default.config.php:48) in .../default.config.php on line 64


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

                I made a: mrhaw.config.php
                and added: &config=`mrhaw`

                No error this way but no change either...
                  @hawproductions | http://mrhaw.com/

                  Infograph: MODX Advanced Install in 7 steps:
                  http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                  Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                  http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                • No error this way but no change either...
                  Have you added &stripInput=`mrhawStripInput` in your snippet call ?
                  You need to have [!AjaxSearch &config=`mrhaw`` &stripInput=`mrhawStripInput` .....
                  • I did it exactly like you say (and as the wiki says) and I can confirm it works with my config file by
                    typing junk in it and get errors...

                    But if I in the non-ajax search also put it in the landing/result page snippet call  - it didnt work.

                    the latest debug:
                    [8-Nov-08 06:22:23]  AjaxSearch 1.8.1 - Php5.2.6 - MySql 4.1.25-Debian_mt1
                    [8-Nov-08 06:22:23]  AjaxSearch - Configuration file mrhaw : 
                    <?php
                    function mrhawStripInput($searchString){
                    
                        if ($searchString !== ''){  
                          // Remove escape characters
                          $searchString = stripslashes($searchString);
                    
                          // Remove modx sensitive tags
                          $searchString = stripTags($searchString);
                    
                          // Remove +something+ substring too
                          $searchString = stripOtherTags($searchString);  
                    
                          // Strip HTML tags
                          $searchString = stripHtml($searchString);  
                        }  
                        return $searchString;
                      }
                    
                    function stripOtherTags($text){
                      // Regular expressions to remove +something+
                      $modRegExArray[] = '~\+(.*?)\+~';   // +phx+
                    
                      // Remove modx sensitive tags
                      foreach ($modRegExArray as $mReg)$text = preg_replace($mReg,'',$text);
                      return $text;
                    }
                    [8-Nov-08 06:22:23]  AjaxSearch - User configuration - Before parameter checking : Array
                    (
                        [config] => mrhaw
                        [version] => 1.8.1
                        [debug] => 3
                        [language] => english
                        [ajaxSearch] => 0
                        [advSearch] => oneword
                        [whereSearch] => content|tv
                        [subSearch] => 5,1
                        [withTvs] => 
                        [order] => publishedon,pagetitle
                        [rank] => pagetitle:100,extract
                        [minChars] => 3
                        [AS_showForm] => 1
                        [resultsPage] => 0
                        [grabMax] => 10
                        [extract] => 1:content,description,introtext,tv_content
                        [extractLength] => 200
                        [extractEllips] => ...
                        [extractSeparator] => <br />
                        [formatDate] => d/m/y : H:i:s
                        [highlightResult] => 0
                        [pageLinkSeparator] =>  | 
                        [AS_landing] => 8
                        [AS_showResults] => 1
                        [idType] => parents
                        [parents] => 
                        [documents] => 
                        [depth] => 10
                        [hideMenu] => 2
                        [hideLink] => 1
                        [filter] => 
                        [tplLayout] => @FILE:assets/snippets/ajaxSearch/templates/layout.tpl.html
                        [tplResults] => @FILE:assets/snippets/ajaxSearch/templates/results.tpl.html
                        [tplResult] => @FILE:assets/snippets/ajaxSearch/templates/result.tpl.html
                        [tplPaging] => @FILE:assets/snippets/ajaxSearch/templates/paging.tpl.html
                        [stripInput] => mrhawStripInput
                        [stripOutput] => defaultStripOutput
                        [searchWordList] => 
                        [breadcrumbs] => 0
                        [tvPhx] => 0
                        [clearDefault] => 0
                        [jsClearDefault] => assets/snippets/ajaxSearch/js/clearDefault.js
                    )
                    
                    [8-Nov-08 06:22:23]  AjaxSearch - tplResult template @FILE:assets/snippets/ajaxSearch/templates/result.tpl.html : <div class="[+as.resultClass+]">
                      <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.longtitle+]">[+as.pagetitle+]</a>
                    [+as.descriptionShow:is=`1`:then=`
                      <span class="[+as.descriptionClass+]">[+as.description+]</span>
                    `+]
                    [+as.extractShow:is=`1`:then=`
                      <div class="[+as.extractClass+]"><p>[+as.extract+]</p></div>
                    `+]
                    [+as.breadcrumbsShow:is=`1`:then=`
                      <span class="[+as.breadcrumbsClass+]">[+as.breadcrumbs+]</span>
                    `+]
                    </div>
                    [8-Nov-08 06:22:23]  AjaxSearch - tplResults template@FILE:assets/snippets/ajaxSearch/templates/results.tpl.html : [+as.noResults:is=`1`:then=`
                      <div class="[+as.noResultClass+]">
                        [+as.noResultText+]
                      </div>
                    `:else=`
                      <p class="ajaxSearch_resultsInfo">[+as.resultInfoText+]</p>
                      [+as.paging+]
                      [+as.listResults+]
                      [+as.paging+]
                    `+]
                    [8-Nov-08 06:22:23]  AjaxSearch - tplResult template@FILE:assets/snippets/ajaxSearch/templates/layout.tpl.html : [+as.showForm:is=`1`:then=`
                    <form [+as.formId+] action="[+as.formAction+]" method="post">
                        <fieldset class="form3">
                    		<input type="hidden" name="advSearch" value="[+as.advSearch+]" />
                        <label for="ajaxSearch_input">
                          <input id="ajaxSearch_input" class="cleardefault" type="text" name="search" value="[+as.inputValue+]"[+as.inputOptions+] />
                        </label>
                        <label for="ajaxSearch_submit">
                          <input id="ajaxSearch_submit" type="submit" name="sub" class="button" value="" />
                        </label>
                        </fieldset>
                    </form>
                    `+]
                    [+as.showIntro:is=`1`:then=`
                    <p class="ajaxSearch_intro" id="ajaxSearch_intro">[+as.introMessage+]</p>
                    `+]
                    [+as.showResults:is=`1`:then=`
                    [+as.results+]
                    `+]
                    


                    The good thing  smiley is that I can turn off highlightning which is causing problem by outputing
                    example: <span="ajax_higlightning ajax_higlightning1 ">bla bla</span> all over in important code.

                    I’m running 0.9.6.2 - My other websites has 0.9.6.1p2 and no PHx installed, but are on same server with same mysql
                    and php. On those its all good except it finds word/term: "modx" on all pages... ?

                    Well, I am thankful for your help.  cool
                      @hawproductions | http://mrhaw.com/

                      Infograph: MODX Advanced Install in 7 steps:
                      http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                      Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                      http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                    • As example see the new stripInput demo on the AjaxSearch demo site.

                      Take care the snippet call of your landing page should contains &config=`mrhaw` &stripInput=`mrhawStripInput` even if the input form is not displayed. See the landing page of the stripInput demo