We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11190
    • 109 Posts
    Hello, all. I’m really braincramping on using AjaxSearch or I’m completely misunderstanding documentation. I am a complete newbie so I’m pretty sure the problem is me but I’ve spent hours searching the forums and checking my syntax.

    I posted yesterday on my goal of having the search in the margin and carried forward in the margin as the user clicks on the search items. While awaiting a response, I thought I would just revert to a simple search. The search form is still in the margin but I then display the results on a separate page. Many of the parameters do not seem to work. I’ve double checked to make sure I’m using back ticks and I’ve played with caching and non-caching snippets and display pages. Here is the current call in the margin (part of my main template):

    [!AjaxSearch? &AS_showResults=`0` &AS_landing=`36` &showMoreResults=`1`&moreResultsPage=`36` &ajaxMax=`2` &grabMax=`2` &extract=`1` !]

    I started much simpler and have added other parameters to help troubleshoot. No matter what the setting of &ajaxSearch (0 or 1), the results are displayed in the margin and document 36 is not called. The search terms are not highlighted. If there are more than two results, the more results link is displayed. Clicking on it does display document 36 but there are no search results displayed. Here is the snippet on document 36:

    [[AjaxSearch? &AS_showForm=`1` &AS_showResults=`1` &AS_landing=`36` &showMoreResults=`1`&moreResultsPage=`36` &ajaxMax=`2` &grabMax=`2` &extract=`1` ]]

    I originally had &AS_showForm=`0`. I set it to 1 because nothing was showing on the page and I wanted to make sure the snippet was being called. Now, the form is shown on the page but no results.

    There are some secondary issues, too. If I click or type in the search from in document 36, the mouse and keyboard events are displayed in the form in the margin. How do I fix that?

    Also, the margin also contains a sign in form. The tab order seems to go from the search text box to the login text box (the login text box tabindex is set to 100) rather than to the Go button. How do I fix that?

    Oh, versions. I am running MODx 0.9.6. I have tried AjaxSearch 1.5 that ships with it and also upgraded to AjaxSearch 1.6 from the MuddyDogPaws site. Same results. I have tried while logged into the manager and logged out.

    Sorry for such a basic post but I’ve not been able to figure this out despite lots of testing and playing with the parameters to try to understand them. Thanks - John
      http://www.spiritualoutreach.com
      Making Christianity intelligible to secular society
      • 4775
      • 47 Posts
      I’m having very similar problems. Maybe this thread bump will get some activity going.
        • 11190
        • 109 Posts
        I do have most of the snippet working but there are still some problems. Here is the snippet call for the search box in my right margin:

        [!AjaxSearch? &ajaxSearch=`0` &AS_showResults=`0` &AS_landing=`36` &showMoreResults=`1` &moreResultsPage=`36` &extract=`1` !]

        Here is the output on document #36:

        [!AjaxSearch? &AS_showForm=`0` &ajaxSearch=`0` !]

        There are two big remaining problems. The snippet still hangs consistently on certain words when ajaxSearch is enabled. I have had to disable. The indexing also does not seem to be working well. There are very common words which return no search results. For example, on http://www.spiritualoutreach.com - site dedicated to explaining Christianity to a secular audience - a search for God shows no results! The searchable flag is set on documents containing that word. Any ideas on how to fix these remaining problems?
          http://www.spiritualoutreach.com
          Making Christianity intelligible to secular society
          • 4310
          • 2,310 Posts
          God is a three letter word and IIRC there’s a four letter limit by default.
          I think it can be adjusted somewhere, but my memory fails me as to where.
            • 5811
            • 1,717 Posts
            I confirm the search is limited to words with at least 4 characters. To change that, open snippets/ajaxSearch/includes/snippet.ajaxSearch.inc.php and line 131 replace :
            $minChars = isset($minChars) ? $minChars : 4;
            by
            $minChars = isset($minChars) ? $minChars : 3;


            In the future, may be I will display a message when the number of letters is shorter than $minChars
              • 11190
              • 109 Posts
              Hmm . . didn’t seem to work for me. I didn’t see snippet.ajaxSearch.inc.php in includes nor any file with $minChars in it. I did find that variable in the AjaxSearch directory in the snippet-ajaxSearch-tpl.php file however the comment seems to say that this is to strip out words less than four characters from the search:

              // Minimum number of characters to require for a word to be valid for searching. MySQL will typically NOT search for words with less than 4 characters (relevance mode). If you have $useAllWords = true and a three or fewer word appears in the search string, the results will always be 0. Setting this drops those words from the search in THAT CIRCUMSTANCE ONLY (relevance mode, useAllWords=true).

              I tried changing it to "2" anyway and it had no effect. I also still have the problem where a search for a word like "journey" on the site results in what appears to be an infinite loop when AjaxSearch is enabled (it is currently disabled). Thanks - John
                http://www.spiritualoutreach.com
                Making Christianity intelligible to secular society
                • 32654
                • 26 Posts
                gracedman,

                I just looked for the $minChars = isset($minChars) ? $minChars : 4; and it is there so I changed it to $minChars : 3;
                and it worked for me.

                The file was in:
                snippets/ajaxSearch/includes/snippet.ajaxSearch.inc.php

                I am using version 1.7.1

                w smiley
                  • 11190
                  • 109 Posts
                  Ah, I’m using 1.6. I’ll upgrade and give it a whirl. Thanks - John
                    http://www.spiritualoutreach.com
                    Making Christianity intelligible to secular society