Downloads » Resources » AjaxSearch » AjaxSearch | 1.8.0

AjaxSearch 1.8.0

  • 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: Jul 24th 2008 | License: GPL - GNU Public | Downloads: 1075

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

See ajaxSearch_version_180.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.3.0 of the plugin Highligth from Sottwell


--- NEW OPTIONS ---


whereSearch: Extend the search to Jot, maxigallery and your custom tables

extract: Define the maximum number of extracts that will be displayed
per document and define which fields will be used to set up extracts

extractEllipsis: Define your ellipsis in extract

extractSeparator: Define how separate extracts

order: Define in which order are sorted the displayed search results

rank: Define the ranking of search results

formatDate: Define the format of displayed dates

hideLink: Search in content of type reference

filter: Exclude unwanted documents of the search

tvPhx: Set placeHolders for TV (template variables)

breadcrumbs: Display the path of documents found

searchWordList: Choose your search term from a predefined search word list

clearDefault: Clearing default text

stripInput: Define your own stripInput user function to use

stripOutput: Define your own stripOutput user function to use


Warning:
searchStyle is now deprecated.
The relevance mode definitively dropped out

stripHtml, stripSnip, stripSnippets are now deprecated
Use your own stripInput and stripOutput user functions.


Documentation:
A documentation folder is provided with the snippet
It contains, some config files and templates files as examples
These files are used by the demo on the demo site www.modx.wangba.fr
You could find also a tutorial to to define search in your own tables



-- CHANGE REQUESTS IMPLEMENTED --

- Extend the search to others tables
Until now AjaxSearch was limited to do the search into the documents ("site_content" table)
and partially into TVs linked to the document ("tmplvar_contentvalues" table).
With the 1.8 version you could now define where to do the search (in which tables)

- Improvement of the extract algorithm
Extracts are now merged if needed to avoid to have an extract per search term.
You can define the number of sub-extracts you want also.

- Extended place holder templating and template parameters

- Use of &advSearch parameter available from the front-end by the end user

- Configuration file and $__ global parameters

- Highligthing plugins
the Highlighting plugin takes now into account of &advSearch parameter.
An advanced Highlighting plugin is provided. You could enclose as many areas as you want.



-- ISSUES CORRECTED --

Search in TVs
And is there any way to return a defined TV as part of the search result?

If you are searching for text in more than one TVs, it can't find the correct entries.
TV1="hi"
TV2="huhu"
search for "hi huhu", you get "nothing found".
http://modxcms.com/forums/index.php/topic,5357.msg143876.html#msg143876


Quoted searchstring
The use of a quote in the search terms makes an error
http://modxcms.com/forums/index.php/topic,5357.msg156763.html#msg156763


urlDecode and htmlentities
The use of a quote in the search terms disable the search terms highlithing
http://modxcms.com/forums/index.php/topic,5357.msg154038.html#msg154038


tag not filtered in strip MODx tags function
http://modxcms.com/forums/index.php/topic,5357.msg136667.html#msg136667


Search doesn't take into account of parameters : parents, documents, hidden, searchable
When a search is done with several search terms with the mode &advSearch = 'oneword',
the search doesn't take into account of parameters : parents, documents, hidden, searchable, published.


AjaxSearch validated in Strict 1.0 (except for the opacity parameter)
http://modxcms.com/forums/index.php/topic,26288.0.html


Doc parsing will result in error when search term contains slashes
Please add / quoting in preg_quote call on line 68. Otherwise doc parsing will result
in ModX error when search term contains slashes.
http://modxcms.com/forums/index.php/topic,1237.msg159062.html#msg159062


Highlighting plugin
Error when highlighting a search term which contains '/'
When attempting to highlight a search term which contains '/' the plugin fails due missing quoting of '/'.
This results in ModX error.
http://svn.modxcms.com/jira/browse/ADDON-2


( back to top )