We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19522
    • 17 Posts
    Odd. I don’t get errors searcing for apostrophe using utf-8 without your patch
      • 17673
      • 194 Posts

      Any chance for support of another standard Ajax form-enhancement: auto-completion in the search field? (Google-suggests kind of ...)

      the list of terms to display dinamically does not necessarily have to be retrieved from the server via XMLHttpRequest, it can be edited by hand in the snippet code and loaded into a Js array...
        ----------------------------------------------------------
        http://www.linkedin.com/in/lucapost/
        http://www.twitter.com/lukwe/
        ----------------------------------------------------------
        • 2328
        • 39 Posts
        A very minor bug in 1.1 for your next release?

        I couldn’t find this mentioned anywhere in the forum so please forgive me if it’s already been reported: there’s a typo in the link code generated for paginated results. The first parameter (AS_offset) is prefixed by & rather than ? - which completely bypasses all the parameters and causes the pagination to fail. It’s line 485 in the source code for the main snippet if that’s any help.
                    $resultPageLinks .= '<a href="[~' . $modx->documentObject['id'] . '~]&AS_offset=' . $nrp . '&AS_search=' . urlencode($searchString) . '">' . $resultPageLinkNumber . '</a>';
        

        Should I put this in the MODx bug tracker or is this sufficient?

        Edit - actually looking at the code, there’s a similar problem on line 534:
                    $SearchForm.='<a class="ajaxSearch_resultLink" href="[~'.$SearchFormsrc['id'].'~]&searched='.urlencode($searchString).'&highlight='.urlencode($highlightClass).'" title="' . $SearchFormsrc['pagetitle'] . '">' . $SearchFormsrc['pagetitle'] . "</a>".$newline;
        


        Jon

        (Who’s new to MODx but generally finding it easy to use!)
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          The MODx parser normally creates links like "index.php?id=xx" when it sees [~xx~], so any additional options need to be with &. Although this can be different if "friendly urls" are used, since then the parser will use the alias to create the URL.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: sottwell at Jan 01, 2007, 02:42 PM

            The MODx parser normally creates links like "index.php?id=xx" when it sees [~xx~], so any additional options need to be with &. Although this can be different if "friendly urls" are used, since then the parser will use the alias to create the URL.
            Though you can still use & because technically, friendly URLs still include ?q=alias in the URL, which is just rewritten without the ?. In my experience, everything still works fine even though the rewritten URLs do not seem to include a ?.
              • 2328
              • 39 Posts
              Quote from: OpenGeek at Jan 01, 2007, 06:15 PM

              Though you can still use & because technically, friendly URLs still include ?q=alias in the URL, which is just rewritten without the ?. In my experience, everything still works fine even though the rewritten URLs do not seem to include a ?.

              I wasn’t aware of that, it seems pretty sensible and covers for pages with GET parameters already present.

              However, it definitely isn’t working for me as written. I’m using MODx 0.9.5 with the full friendly alias path option turned on (I like the semblance of a site structure in the urls). All the links are generating the likes of:

              http://localhost/searchresults.html&AS_offset=10&AS_search=testsearch


              Click on the link, and you get a blank results page with a request to enter a search term to begin the search.

              If I enter the fix I described, it works fine.

              Could it be a bad setting in my system?

              Jon
                • 22303 MODX Staff
                • 10,725 Posts
                Honestly, that code should be using the $modx->makeUrl() function; something like this...
                $resultPageUrl= $modx->makeUrl($modx->documentIdentifier, '', 'AS_offset=' . $nrp . '&AS_search=' . urlencode($searchString));
                $resultPageLinks .= '<a href="'. $resultPageUrl .'">' . $resultPageLinkNumber . '</a>';
                  • 2328
                  • 39 Posts
                  Thanks for the quick response there, Jason!

                  I think you’re right and it would be a lot more robust smiley

                  I think I might make that change locally and hope it shows up in a future incarnation of AjaxSearch smiley

                  Since I don’t use the Ajax part of the search (pretty as it is), I might branch off in my own direction with this snippet anyway wink

                  I’ll certainly check my own snippets as I’m sure I’ve been creating urls in the same way.

                  Jon
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    The Ajax part can be turned off, just set &ajaxSearch=`0` and it’s a standard search tool.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 2328
                      • 39 Posts
                      Quote from: sottwell at Jan 02, 2007, 12:32 PM

                      The Ajax part can be turned off, just set &ajaxSearch=`0` and it’s a standard search tool.

                      That’s what I’ve done - just seems a lot of code sitting around unused if I do! (I can be obsessively neat and tidy sometimes smiley I have to do some rewriting anyway, so I can search my maxigallery descriptions and the content produced by a forum snippet I’ve written. I also want to produce a more sophisticated search in the long run, including partial matches and filtering by website section. While I’m pretty good with php, javascript (or more accurately, the DOM) confuses me no end, so I’d be happy to chop out the extras smiley

                      Ideally, what I’d like to be able to do is have ajax, but divert the results to replace the page content - but that’s so close to what happens without the Ajax, it’s not worth bothering with.

                      FYI, Opengeek’s fix worked a treat smiley

                      Hmm, a thought, I wonder if it’s possible to parameterise the ids for the search form. I’d like to combine results and advanced search on the same page, but with the sidebar version of the search form, I get duplicate ids at the moment...

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