Downloads » Resources » AjaxSearch » AjaxSearch | 1.7.1

AjaxSearch 1.7.1

  • Currently 4.675/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
40 vote(s).

Resource ImageAjaxSearch 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.

Works with MODx Version(s): 0.9.6
Submitted: Mar 7th 2008 | License: GPL - GNU Public | Downloads: 1894

Description

This snippet creates a search box and the results form. The search results 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.

The search could be limited to a subset of documents with the use of parents or documents parameters.

You could use AjaxSearch with your own custom tables.

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: This code runs with the mootools librairy, provided with MODx.

  • 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 contents of the file snippet.ajaxSearch.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 files from the zip to the ajaxSearch folder.
  • 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!

Updates

AjaxSearch - version 1.7.1

See ajaxSearch_version_1.7.1.txt in the zip file
the wiki documentation http://wiki.modxcms.com/index.php/AjaxSearch
Demo site : http://www.modx.wangba.fr

Includes the version 1.2.1 of the plugin Highligth from Sottwell

--- NEW OPTIONS ---

CAUTION: &useAllWords is now deprecated and replace by &advSearch = "allwords"

&advSearch [ 'exactphrase' | 'allwords' | 'nowords' | 'oneword' ]

Advanced search:
- exactphrase : provides the documents which contain the exact phrase
- allwords : provides the documents which contain all the words
- nowords : provides the documents which do not contain the words
- oneword : provides the document which contain at least one word [default]

&hideMenu [ 0 | 1 | 2 ]

Search in hidden documents from menu
- 0 : search only in documents visible from menu
- 1 : search only in documents hidden from menu
- 2 : search in hidden or visible documents from menu [default]


-- CHANGE REQUESTS IMPLEMENTED --

- search in hidden documents from menu
http://modxcms.com/forums/index.php/topic,5357.msg144232.html#msg144232

Documents flaged with hidden should only be shown in the result list, if the user wants to.

- advanced search
The following search are now allowed:
* exactphrase : the exact phrase is used as searchstring
* allwords : search the documents which contains all the search terms
* oneword : search the documents which contains at least one word
* nowords : search the documents which do not contain the words


-- ISSUES CORRECTED --
http://modxcms.com/forums/index.php/topic,5357.msg139525.html#msg139525

Extract with a % percent character freeze the display of the results output
Unuseless usage of the decodeURIComponent function in js/ajaxSearch.js (line 162)


Correction of search with searchStyle = "relevance"
Do a full text search in pagetitle, description and content fields. Use LIKE for others fields
FULLTEXT indexes exists only for `pagetitle`,`description`,`content`


( back to top )