AjaxSearch 1.0
AjaxSearch allows your site visitors to search your site without leaving the page they are on. The results are returned via an ajax request and loaded into the results box below the search form.
Submitted: Jun 23rd 2006 | License: GPL - GNU Public | Downloads: 3906
Description
This snippet creates a search box and the reults from the search are loaded right in the page for the user. If the user does not have javascript, the snippet will use the default searching of the FlexSearchForm snippet. A search term highlighting plugin has been included as well.
If the user does not have javascript enabled they can still search your site. In this case the search results are returned in a new page.
You can also include search term highlighting that is carried through to the linked page.
Note: For this code to work you must include a call to the prototype and the script.aculo.us javascript libraries in your template. This is done automatically with the addJscript parameter unless you set it to 0.
- This code is based off of the FlexSearchForm snippet created by jaredc.
- The javascript code is based off of the example by Steve Smith of orderedlist.com.
- The search highlighting plugin is modified from Susan Ottwell's (http://www.sottwell.com) original code.
Instructions
Follow these steps to install this snippet:
- Copy the index-ajax.php to the root-level of your MODx installation.
- Copy the contents of the file snippet-ajaxSearch-tpl.php into a new snippet named AjaxSearch
- Create a directory named AjaxSearch under the assets/snippets folder.
- Open the AjaxSearch.js file and set the loading & close image path to an image you want to display while the search is working.
- Copy the following files and the loading/closing images as appropriate into the AjaxSearch folder. AjaxSearch.js, AjaxSearch.php, AjaxSearch.inc.php
- Add the snippet call like the following: [!AjaxSearch? &AS_showResults=`0` &AS_landing=`17` &showMoreResults=`1` &moreResultsPage=`17`!]
- Use the styles to customize the look of your output.
- If you are using the display more results link setup a new page with the snippet call to display your results.
- Test and see the search working with AJAX!