We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18367
    • 834 Posts
    I’ve got Ajax Search working in it’s basic form, but I want to enable the advanced option search as per the demo site. http://www.modx.wangba.fr/index.php?id=144

    I tried using the code given but it just appears as code on my search page.

    [!AjaxSearch? &ajaxMax=`4` &extract=`99` &tplLayout=`optionSearch` &showMoreResults=`1` &moreResultsPage=`169`!]


    and I created a chunk called optionSearch based on the one in the included templates.

    I’ve probably missed a step or two, so any help would be appreciated.

    Thanks



      Content Creator and Copywriter
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Are you sure the snippet name is exactly AjaxSearch? Usually when the snippet call appears as text in the output it’s because the snippet wasn’t found due to a typo in the snippet name/snippet call.
        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
        • 10487 MODX Staff
        • 1,535 Posts
        Also, did you copy and paste the snippet call directly from the wangba.fr site?

        If you did, that might be your problem. The snippet call on that demo page has been constructed in a way that it won’t be parsed by the MODx parser (for obvious demo purposes). Best option would be to delete the snippet call and manually type it in to avoid that particular issue.
          Garry Nutting
          Senior Developer
          MODX, LLC

          Email: [email protected]
          Twitter: @garryn
          Web: modx.com
          • 18367
          • 834 Posts
          Garryn,

          well that is truly weird.

          I retyped the call as you said and it worked.

          Thing is I can’t see the difference between the two.

          Huh?

          Here’s both. The top one is the copy and paste that doesn’t work, the bottom one is the retyped version that does.

          [!AjaxSearch? &ajaxMax=`4` &extract=`99` &tplLayout=`optionSearch`
          &showMoreResults=`1` &moreResultsPage=`169`!]
          
          [!AjaxSearch? &ajaxMax=`4` &extract=`99` &tplLayout=`optionSearch` &showMoreResults=`1` &moreResultsPage=`169` !]
          


          Very spooky, Mulder.

          Thanks anyway.

            Content Creator and Copywriter
            • 10487 MODX Staff
            • 1,535 Posts
            All in the HTML source wink Here’s what you would have copied from wangba.fr:
            <span class="bracket">[</span>!AjaxSearch? &ajaxMax=`4` &extract=`99` &tplLayout=`optionSearch` &showMoreResults=`1` &moreResultsPage=`169`!<span class="bracket">]</span>
            

            Notice how the span tags are placed, that is to stop MODx from parsing the snippet. When you copied and pasted (into TinyMCE I presume) you would have got the HTML code copied over even though, visually, the snippet calls look the same.

            Anyway, glad you got it working smiley
              Garry Nutting
              Senior Developer
              MODX, LLC

              Email: [email protected]
              Twitter: @garryn
              Web: modx.com
              • 18367
              • 834 Posts
              Hmmm,

              maybe, but both the examples I pasted below are direct from the html source editor.

              Anyway, I never trust TinyMCE with code. (Or any wysiwyg for that matter.)

              And I don’t like TinyMCE’s source editor that much either. Note to self: In future toggle Edit Area on when writing code. grin

                Content Creator and Copywriter
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Ah, the linebreak in the first one killed it. Snippet calls and all their parameters have to be on one line.

                That’s why a lot of the complex snippets are now offering the use of external config.php files, so you only need one parameter, the name of your config file. You put the appropriately named config.php file in the assets/snippets/snippetname/config folder, and use standard PHP variable assignment lines to set the parameters. Makes life a lot easier when you’ve got a dozen or so complex parameters in a snippet call.
                  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