We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32986
    • 17 Posts
    how to make modx search my site..i created a form in xhtml

    <div>
    <form id="search" method="post" action="/">
    <input type="text" id="box" value="..." class="swap_value" />
    <input type="image" src="images/searchbutton.png" id="go" alt="Search" title="Search" />
    </form>
    </div>

    it looks something like these..



    i just want simple results mostly based on title or description of a page..
    • That’s what the AjaxSearch snippet is for. There is extensive documentation on how to use it here http://wiki.modxcms.com/index.php/AjaxSearch
        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
        • 32986
        • 17 Posts
        thanks for the reply..

        the problem is how put the snippet to my html code... because the documentation is not noob friendly..there is no example or screenshot what to put in the search button (or go button) on my html code to be able the snippet to work..there should be a trigger modx code there... (i dont want the ajaxsearch styles)..
          • 26931
          • 2,314 Posts
          Hi xzsurf,

          maybe also have a look at the example content/website that comes with the MODx installation
            • 32986
            • 17 Posts
            the default website from modx uses ajaxsearch and not showing results in other pages(it just show results on the text field)...and ajaxsearch uses own templates..
            i just want a simple search function using my own style/design...
              • 4532
              • 11 Posts
              Hi xzsurf

              Below is the call that I have in my site.

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

              &ajaxSearch=`0` = dissables the Ajax features of the search
              &AS_landing=`17` = is the page id where the results will show
              &AS_showResults=`0` = tells it not to show the results

              and below is the snippet call on the search results page.

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

              &AS_showForm=`0` = don’t show the search form in this snippet call

              Hope this helps smiley
              • Put your HTML in a chunk. Use the chunk name in the AjaxSearch snippet as a parameter, &tplLayout=`name-of-chunk`.
                [!AjaxSearch? &AjaxSearch=`0` &AS_showResults=`0` &AS_Landing=`xxx` &tplLayout=`name-of-chunk`!]

                The `xxx` for the landing page should be the ID of the document you want to use to show the results. In that document, have another AjaxSearch snippet call to get the results:
                [!AjaxSearch? &ajaxSearch=`0` &AS_showForm=`0`!]



                  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
                  • 5811
                  • 1,717 Posts
                  As explained by Susan, use the layout template. &tplLayout=`yourOwnLayoutTpl`

                  To get:
                  <div>
                  <form id="search" method="post" action="/">
                  <input type="text" id="box" value="..." class="swap_value" />
                  <input type="image" src="images/searchbutton.png" id="go" alt="Search" title="Search" />
                  </form>
                  </div>

                  it looks something like these..


                  Takes the templates/layout.tpl.html template:
                  [+as.showForm:is=`1`:then=`
                  <form [+as.formId+] action="[+as.formAction+]" method="post">
                      <fieldset>
                      <input type="hidden" name="advSearch" value="[+as.advSearch+]" />
                      <label for="ajaxSearch_input">
                        <input id="ajaxSearch_input" class="cleardefault" type="text" name="search" value="[+as.inputValue+]"[+as.inputOptions+] />
                      </label>
                      <label for="ajaxSearch_submit">
                        <input id="ajaxSearch_submit" type="submit" name="sub" value="[+as.submitText+]" />
                      </label>
                      </fieldset>
                  </form>
                  `+]
                  [+as.showIntro:is=`1`:then=`
                  <p class="ajaxSearch_intro" id="ajaxSearch_intro">[+as.introMessage+]</p>
                  `+]
                  [+as.showResults:is=`1`:then=`
                  [+as.results+]
                  `+]

                  Customize it to feet your own needs. For instance:
                  [+as.showForm:is=`1`:then=`
                  <form [+as.formId+] action="[+as.formAction+]" method="post">
                      <fieldset>
                      <input type="hidden" name="advSearch" value="[+as.advSearch+]" />
                      <label for="ajaxSearch_input">
                        <input id="ajaxSearch_input" class="cleardefault" type="text" name="search" value="[+as.inputValue+]"[+as.inputOptions+] />
                      </label>
                      <label for="ajaxSearch_submit">
                        <input id="ajaxSearch_submit" type="image" name="sub" src="images/searchbutton.png" />
                      </label>
                      </fieldset>
                  </form>
                  `+]
                  [+as.showResults:is=`1`:then=`
                  [+as.results+]
                  `+]
                  Here I have replaced the Go button by your image and suppress the introduction message displayed under the search form.
                  If you are not interesting by the clearDefault option you could also remove the use of the class clearDefault
                  &clearDefault
                  clearing default text. (optional) add the class "cleardefault" to your input text form and set this parameter
                  Don’t remove the placeholders and keep the structure of the template.


                  And obviously, define the css styles of the input form elements by modifying:

                  #ajaxSearch_form
                  #ajaxSearch_input
                  #ajaxSearch_submit

                  To style the results page, customize the templates results and result and the parameters &tplResults and tplResult.
                    • 32986
                    • 17 Posts
                    can i use other than ajaxsearch...but thanks anyway..
                      • 32986
                      • 17 Posts
                      still cant use my ow template..any other way other than ajax search?