We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 785
    • 2,113 Posts
    Error if is present a blank in the beginning of search text, for example:
    If on http://www.modx.wangba.fr/index.php?id=143 search " primary school" (not "primary school") you receive:
    Warning: mb_strpos() [function.mb-strpos]: Empty delimiter. in /homepages/44/d216423952/htdocs/mod2/assets/snippets/ajaxSearch180/classes/search.class.inc.php on line 752

    It is necessary to add trim.
      Создание сайтов на MODx, поддержка сайтов, поисковая оптимизация, программирование, копирайтинг
      Статьи о MODx, регулярно новые публикации
      • 7231
      • 4,205 Posts
      AKots: good catch. Coroico is not going to be around for a few weeks. If you could help prepare a fix for this we can post it here until it can be added to the official release.
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don't know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 785
        • 2,113 Posts
        Quote from: dev_cw at Jul 29, 2008, 06:26 AM

        If you could help prepare a fix for this we can post it here until it can be added to the official release.
        About trim:
        I think, in function defaultStripInput (file search.class.inc.php)
        after command
        if ($searchString !== ''){  

        add:
        $searchString = trim($searchString);

          Создание сайтов на MODx, поддержка сайтов, поисковая оптимизация, программирование, копирайтинг
          Статьи о MODx, регулярно новые публикации
          • 33372
          • 1,611 Posts
          I haven’t looked at the code, but it seems to me as if the trim is only fixing the issue with spaces at the beginning or end of the entered search term. However the script still throws a parse error (below) if the user enters two or more spaces between words in the query (e.g., "ecuador peru"). Looks to me that the search query is being exploded using spaces but zero-character fragments aren’t being discarded before passing them to strpos().

          Error: strpos() [function.strpos]: Empty delimiter
          Error type/ Nr.: Warning - 2
          File: /path/to/my/install/assets/snippets/ajaxSearch/classes/search.class.inc.php
          Line: 1096
          Line 1096 source: $wordLeft = $mbStrpos($mbStrtolower($text), $mbStrtolower($searchTerm))

          Also: I thought that I would fix the issue on my site by using the exactphrase method, but it’s not working for me at all (even when I hard-code it in the snippet itself). It’s not just that the highlighting plugin doesn’t respect this setting (as mentioned here). It’s still searching using the oneword method (and in fact it ignores allwords as well, so the config is just not being respected as far as I can tell).

          I’m also getting the PHx placeholder code from results.tpl.html outputted to the screen periodically, and I think that I figured out that it happens if the search query includes "is a" (e.g., "that is a bug"). That would make me believe that there are probably other similar terms that would also cause this sort of thing, and that it could occur with any of the templates. So you should probably review how you’re parsing through the results (could you replace the PHx code before the other placeholders so that you don’t replace PHx code by accident?).

          And lastly (sorry for all this!), I stumbled upon another weird glitch in the highlighting plugin. If I search for something like "ecuador span" or even "ecuador pan" the highlighting code gets broken up and spit out in the results in a really weird way (as strikethrough text).

          I’m using AjaxSearch 1.8.1 on MODx 0.9.6.3 in non-Ajax mode.
            "Things are not what they appear to be; nor are they otherwise." - Buddha

            "Well, gee, Buddha - that wasn't very helpful..." - ZAP

            Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
            • 33372
            • 1,611 Posts
            Quote from: ZAP at Jan 07, 2009, 06:19 PM

            Also: I thought that I would fix the issue on my site by using the exactphrase method, but it’s not working for me at all (even when I hard-code it in the snippet itself). It’s not just that the highlighting plugin doesn’t respect this setting (as mentioned here). It’s still searching using the oneword method (and in fact it ignores allwords as well, so the config is just not being respected as far as I can tell).
            A little more info on this...

            I skimmed through search.class.inc.php a bit to see if I could figure out why the advSearch parameter wasn’t working. I found that if I add $advSearch=’allwords’; as the first line in the function getHaving() function it works, which makes me think that the value isn’t being passed to that function properly. I see that on line 48 it’s called as $having = $this->getHaving($searchString,$this->advSearch); so maybe that’s not the correct reference or there’s a typo earlier in the class.

            Sorry I can’t investigate any further right now - still way too much to do before morning!
              "Things are not what they appear to be; nor are they otherwise." - Buddha

              "Well, gee, Buddha - that wasn't very helpful..." - ZAP

              Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
              • 5811
              • 1,717 Posts
              Regarding :
              However the script still throws a parse error (below) if the user enters two or more spaces between words in the query (e.g., "ecuador peru"). Looks to me that the search query is being exploded using spaces but zero-character fragments aren’t being discarded before passing them to strpos().
              Change the line 101 of classes/search.inc.class:
                  $searchString = trim($searchString);
              by
              $searchString = preg_replace('/\s\s+/', ' ', trim($searchString));
              to solve this issue. I have registered this issue as [AJAXSEARCH-19].

              :I’m also getting the PHx placeholder code from results.tpl.html outputted to the screen periodically, and I think that I figured out that it happens if the search query includes "is a" (e.g., "that is a bug"). That would make me believe that there are probably other similar terms that would also cause this sort of thing, and that it could occur with any of the templates. So you should probably review how you’re parsing through the results (could you replace the PHx code before the other placeholders so that you don’t replace PHx code by accident?).
              I will try it, to change the parsing approach to avoid this kind of issue. Registered as [AJAXSEARCH-20].

              If I search for something like "ecuador span" or even "ecuador pan" the highlighting code gets broken up and spit out in the results in a really weird way (as strikethrough text)
              . Registered as [AJAXSEARCH-21]

              Thanks Zap for your feedback about these issues

                • 33372
                • 1,611 Posts
                Quote from: coroico at Jan 08, 2009, 05:23 PM

                Regarding :
                However the script still throws a parse error (below) if the user enters two or more spaces between words in the query (e.g., "ecuador peru"). Looks to me that the search query is being exploded using spaces but zero-character fragments aren’t being discarded before passing them to strpos().
                Change the line 101 of classes/search.inc.class:
                    $searchString = trim($searchString);
                by
                $searchString = preg_replace('/\s\s+/', ' ', trim($searchString));
                to solve this issue. I have registered this issue as [AJAXSEARCH-19].
                That does indeed do the trick - thanks for the fix!
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 5811
                  • 1,717 Posts
                  Find enclosed a fix for the version 1.8.1. This fix solve the issues [AJAXSEARCH-21] and [AJAXSEARCH-13]
                  Simply replace the file classes/search.class.inc.php by the this new file.

                  This fix solve only this issue. Rather to replace the search.class.inc.php you could also merge the patch file patch181d.txt with your search.class.inc.php file.

                  This correction will be ported to the version 1.8.2. To see the differences do a search with ecuador pan as search terms with the version 1.8.1 and with the version 1.8.2
                    • 33372
                    • 1,611 Posts
                    Works like a charm - THANKS!
                      "Things are not what they appear to be; nor are they otherwise." - Buddha

                      "Well, gee, Buddha - that wasn't very helpful..." - ZAP

                      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options