Downloads » Resources » AjaxSearch » AjaxSearch | 1.7.0.2

AjaxSearch 1.7.0.2

  • 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: Jan 9th 2008 | License: GPL - GNU Public | Downloads: 1386

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.

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.0.2

See ajaxSearch_version_17.txt in the zip file
and the wiki documentation http://wiki.modxcms.com/index.php/AjaxSearch

Includes the version 1.2.0.2 of the plugin Highligth from Sottwell

Important installation note : the snippet folder has been renamed ajaxSearch. The 1.6 name was AjaxSearch. So you need to create a new directory.


--- NEW OPTIONS ---

&parents [comma-separated list of integers MODx document IDs] (optional)
A list of parent-documents whose descendants you want searched to &depth
depth when searching. All parent-documents by default

&depth [int] (optional)
Number of levels deep to go.
Any number greater than or equal to 1. All levels by default

&documents [comma-separated list of integers MODx document IDs] (optional)
A list of documents where to search

&extractLength [int] (optional)
Length of extract around the search words found
between 50 and 800 characters. 200 by default

&opacity [float value between 0. and 1.] (optional)
Opacity of the ajaxSearch_output div where are returned the ajax results.
Défault is 1. Float value between 0. (transparent) and 1. (opaque)

&useAllWords [ 1 | 0 ] (optional)
If you want only documents which contain ALL words in the search string, set to true
Otherwise, the search will return all pages with ONE or more of the search words. Default 0 (False))

&config [config_name | "default"] (optional)
Load a custom configuration
config_name - Other configs installed in the configs folder or in any folder within the MODx base path via @FILE
Configuration files are named in the form: <config_name>.config.php


-- CHANGE REQUESTS IMPLEMENTED --

- Searching for words containing characters like "å,ä,ö,Å,Ä,Ö".
- Take into account of non utf8 database (latin1, latin2, ..)
- Management of the opacity with IE (+FF, Opera)
- Add a selection of documents where to search
- Add a config file for default parameters
- Strip html tags in title, long title and description output results


-- ISSUES CORRECTED --

http://modxcms.com/forums/index.php/topic,20128.msg125501.html#msg125501
With an utf8 database connection charset, the php_mbstring extension is required

http://modxcms.com/forums/index.php/topic,5357.msg128813.html#msg128813
$database_connection_charset variable undefined

http://modxcms.com/forums/index.php/topic,19755.msg130245.html#msg130245
Javascript variables initialisation appears twice in the html code source

http://modxcms.com/forums/index.php/topic,21047.msg131003.html#msg131003
The strip html tags works only for the first page found

- Security patch :
http://modxcms.com/forums/index.php/topic,5357.msg131495.html#msg131495

- memory fault when ListIDs='' and depth hight
http://modxcms.com/forums/index.php/topic,5357.msg125737.html#msg125737
http://modxcms.com/forums/index.php/topic,5357.msg126745.html#msg126745
http://modxcms.com/forums/index.php/topic,21047.msg131559.html#msg131559

- The searchword highlighted is not in the middle of the extract


( back to top )