We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5675
    • 120 Posts
    When i try to find some phone numbers in my site it works only if i type phone as writen in article. So AjaxSearch can find number like "123-45-67" and "123-45" but NO "123 45 67" or "1234567" when in article is writen as "123-45-67"... How to fix that? I can’t recommend to users to type so strict, search field uses not only for phone numbers.

      Автор благодарит алфавит за любезно предоставленные буквы
      • 5811
      • 1,717 Posts
      So AjaxSearch can find number like "123-45-67" and "123-45" but NO "123 45 67" or "1234567" when in article is writen as "123-45-67"
      May be the solution for you is to use your own stripInput function to convert the searchterm typed by the user.
      ---- &stripInput user function     (optional)
              to transform on fly the search input text
              by default: defaultStripInput
      
              StripInput user function should be define in the config file as follow :
      
              // StripInput user function.
              // string functionName(string $searchstring)
              // functionName : name of stripInput function passed as &stripInput parameter
              // $searchstring : string php variable name as searchString input value
              // return the filtered searchString value
              /*
              function myStripInput($searchString){
      
                  Any Php code which filter the input search string
                  The following internal functions could be called:
                    $searchString = stripHtml($searchString) : strip all the html tags
                    $searchString = stripHtmlExceptImage($searchString) : strip all the html tags execpt image tag.
                    $searchString = stripTags($searchString) : strip all the MODx tags
                    $searchString = stripSnip($searchString) : strip all the snippet names
      
                  You could also developp you own filter based on regular expressions.
                  See http://fr.php.net/manual/en/intro.pcre.php
      
                return $searchString;
              }
      
              By default : defaultStripInput function will be used if &stripInput parameter
              is not set or if the function is not defined :
      
              function defaultStripInput($searchString){
      
                if ($searchString != ''){
                  // Remove escape characters
                  $searchString = stripslashes($searchString);
      
                  // Remove modx sensitive tags
                  $searchString = stripTags($searchString);
      
                  // Strip HTML tags
                  $searchString = stripHtml($searchString);
                }
                return $searchString;
              }