We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1511
    • 144 Posts
    On one of my sites I’m using AjaxSearch 1.5 (original from the MODx 0.9.6-RC1 bundle) with the following parameters...
    Actually, I’m not using the "ajax" part but all the same.

    Call in the template:
    [!AjaxSearch? &AS_showForm=`1` &language=`slovenian` &AS_landing=`30` &addJscript=`1` &extract=`1` &AS_showResults=`0` &ajaxSearch=`0` &depth=`11` !


    And my result page (id=30) call looks like this:
    [[AjaxSearch? &AS_showForm=`0` &AS_showResults=`1` &language=`slovenian` &ajaxSearch=`0` ]]
    


    I hope it helps.
      • 14050
      • 788 Posts
      andrazk,

      So does your search form show on the results page? I think the problem people are having is when they have the AjaxSearch call in their template to place the search form in one location (i.e. sidebar, header) and then create a results page, with another call to AjaxSearch in the content of that page. The problem is that the call in the content usually has &AS_showForm=`0`, which seems to kill the search form from the call in the template. So is there a better way to accomplish this?

      Jesse
        Jesse R.
        Consider trying something new and extraordinary.
        Illinois Wine

        Have you considered donating to MODx lately?
        Donate now. Every contribution helps.
        • 1511
        • 144 Posts
        If I change the AS_showForm to 1 then it shows the form on the "landing page".

        Ah, yes! Now I remember, what I’ve changed. All the "include_once" in the snippet were changed to "include", otherwise the templates for the form were not loaded.
        check this: http://modxcms.com/forums/index.php/topic,5357.msg82410.html#msg82410
          • 14050
          • 788 Posts
          Here is where my problem is, and this may be related to the newest AjaxSearch 1.6. If it is, maybe it is a bug.

          In MODx 0.9.5 with AjaxSearch 1.1, it exhibits the behavior I expect for non-ajax search. I type in the search form, and the results page displays, and the search form doesn’t disappear.

          Example can be seen here (search for "design"):

          http://cmssandbox.com/MODx095/

          The call for the search form is located in the template and is:

           [!AjaxSearch? &extract=`1` &ajaxSearch=`0` &AS_showResults=`0` &AS_landing=`8`!]


          The call for the results is located in the content of the page with the ID of 8, and is:

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


          Now if I use these same calls (changing the landing ID of course) on a 0.9.6 rev 2446 with AjaxSearch 1.6 installed, I get no search results at all.

          Example can be seen here (search for "Bullet")
          http://cmssandbox.com/rms/modx/index.php?id=2

          This isn’t completely unheard of that the same call wouldn’t work, but maybe not intended? (Not having the &ajaxSearch=`0` in the parameter call is what causes it not to return any results) However, on this same install if I change my calls, by adding the &ajaxSearch=`0` parameter to the landing page.

          Call in template:

          [!AjaxSearch? &ajaxSearch=`0` &AS_landing=`6`  &AS_showResults=`0`!]


          Call in the content of the result page:

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


          Then I get results returned, but the search form from the template call disappears. Take a look at the example here (search for "Bullet"):

          http://cmssandbox.com/rms/modx/

          In my mind, the search form disappearing is likely a bug, considering this didn’t happen with the 1.1 version in the 0.9.5 install. Requiring the &ajaxSearch=`0` on the call in the landing page is likely from changing the default value if the parameter is not set, am I correct with that?
            Jesse R.
            Consider trying something new and extraordinary.
            Illinois Wine

            Have you considered donating to MODx lately?
            Donate now. Every contribution helps.
            • 24495
            • 407 Posts
            Because of that behaviour I returned to AjaxSearch 1.1 (http://modxcms.com/forums/index.php/topic,5357.msg89101.html#msg89101). And I’m waiting for a solution too.
              • 14050
              • 788 Posts
              Unfortunately, 1.1 doesn’t search TVs. I guess we can’t have our cake and eat it too :’(
                Jesse R.
                Consider trying something new and extraordinary.
                Illinois Wine

                Have you considered donating to MODx lately?
                Donate now. Every contribution helps.
                • 1511
                • 144 Posts
                If you want to, please, send me your version of AjaxSearch files and snippet and I can look into it.
                On my production sites I’m using AjaxSearch 1.5 and have achieved the same behavior as with version 1.1.

                Contact me via PM so I can send you my email address. I’ll have time to look into it not before Monday.
                  • 24495
                  • 407 Posts
                  @andrazk: it’s AjaxSearch 1.6 from http://modxcms.com/forums/index.php?action=dlattach;topic=11228.0;attach=4364

                  It doesn’t work with two calls on same page (= landing page) in both modx 0.9.5 and 0.9.6 RC. One call is for showing the search form in marginal column, the other call is for showing search results without form (like described here by jesster444: http://cmssandbox.com/rms/modx/)
                    • 1511
                    • 144 Posts
                    Well, I did just a quick test with the resources you gave me the link to and here’s the results.

                    One call in the template
                    [!AjaxSearch? &AS_showForm=`1` &AS_landing=`8`  &extract=`1` &AS_showResults=`0` &ajaxSearch=`0`  !]

                    One call on the landing page
                    [[AjaxSearch? &AS_showForm=`1` &AS_showResults=`1` &ajaxSearch=`0` ]]
                    
                    Landing page is NOT cached.

                    And in the snippet code, just after the configuration code, replace the "almost the same" code with this:
                    /* -------------
                      End configure
                     -------------- */
                    
                    // Set Snippet Paths
                    $snipPath = $modx->config['base_path'] . "assets/snippets/";
                    
                    include_once $snipPath."AjaxSearch/includes/AjaxSearch.inc.php";
                    include $snipPath."AjaxSearch/includes/templates.inc.php";
                    
                    #include default language file
                    include($snipPath."AjaxSearch/lang/english.inc.php");
                    
                    #include other language file if set.
                    $as_language = isset($language) ? $language : $modx->config['manager_language'];
                    if($as_language!="english" && $as_language != '') {
                    	if(file_exists($snipPath ."AjaxSearch/lang/".$as_language.".inc.php"))
                    		include $snipPath ."AjaxSearch/lang/".$as_language.".inc.php";
                    }
                    
                    $liveSearch = $ajaxSearchType;
                    


                    All "include_once" were replaced by "include" EXCEPT in one case, for the inclueds/AjaxSearch.inc.php file.

                    The parameter AS_showForm works as it should, the search works for both searchboxes, when both are displayed.

                    I hope it works for you as it does for me. wink
                      • 14050
                      • 788 Posts
                      That does work! Thanks a bunch. Now that I come to think about it, it makes sense. I would consider this a bug, and it should be submitted as a fix.
                        Jesse R.
                        Consider trying something new and extraordinary.
                        Illinois Wine

                        Have you considered donating to MODx lately?
                        Donate now. Every contribution helps.

                      This discussion is closed to further replies. Keep calm and carry on.