ez.no / exponential / documentation / customization / components / search / custom search box
You can easily add a search form anywhere in your templates which will search specific classes, subtrees etc.
You can use the POST variables SubTreeArray[] to specify specific searches in one or more subtrees. Here you see an example which will search from node 42 and 100.
<form�action={"/content/search/"|ezurl}�method="get"> <input�class="searchbox"�type="text"�size="8"�name="SearchText"�id="Search"�value=""�/> <input�class="searchbutton"�name="SearchButton"�type="submit"�value="Search"�/> <input�type="hidden"�name="SubTreeArray[]"�value="42"�/> <input�type="hidden"�name="SubTreeArray[]"�value="100"�/> </form>
You can search specific classes. For example you can search only forum messages, articles, products etc. This only works with the advanced search.
Below is an example of how you can create a search form which only searches in objects of class 14.
<form�action={"/content/advancedsearch/"|ezurl}�method="get"> <input�class="searchbox"�type="text"�size="8"�name="SearchText"�id="Search"�value=""�/> <input�class="searchbutton"�name="SearchButton"�type="submit"�value="Search"�/> <input�type="hidden"�name="SearchContentClassID"�value="14"�/> </form>
You can search in specific attributes only. The following example will search only in the description attribute of the Folder class:
<form action={"/content/advancedsearch/"|ezurl} method="get"> Search in folder description: <input type="hidden" name="Content_search_attribute_fulltext_classattribute_id[]" value="156" /> <input type="text" name="Content_search_attribute_fulltext_value[]" value="{$search_array_by_class_attribute_id['156']['value']}" /> <input type="submit" value="Search" name="SearchButton"> </form>
Note:
- You must set AllowEmptySearch=enabled in [SearchSettings] in your site.ini(.append) for this to work, because the normal search field is not used.
- The content attribute is specified by ID. The ID may be different on your installation. See the class view for your attribute IDs.
- If you search by several attributes at once, you will only get results where all attributes match. In other words, only AND search is supported, not OR or NOT search.
These attribute search types are supported:
|
Search type |
Parameters |
Provides |
|
fulltext |
classattribute_id, value |
Searches for the text given by value in the attribute given by classattribute_id. |
|
patterntext |
classattribute_id, value |
Searches for the text given by value in the attribute given by classattribute_id. Allows wildcards. |
|
integer |
classattribute_id, value |
Searches for the integer given by value in the attribute given by classattribute_id. |
|
integers |
classattribute_id, values |
Searches for the integers given by values in the attribute given by classattribute_id. Supply the values as separate input fields, named Content_search_attribute_integers_values[][]. |
|
byrange |
classattribute_id, from, to |
Searches for integers between the values given by from and to, in the attribute given by classattribute_id. |
|
byidentifierrange |
identifier, from, to |
Searches for integers between the values given by from and to, in the attributes given by identifier. Since this search uses identifier instead of class attribute ID, it supports searching in several classes at once. |
|
integersbyidentifier |
identifier, values |
Searches for the integers given by values in the attributes given by identifier. Supply the values as separate input fields, named Content_search_attribute_integers_values[][]. Since this search uses identifier instead of class attribute ID, it supports searching in several classes at once. |
You need one form element for each search parameter. The elements should be named "Content_search_attribute_(SEARCH TYPE)_(PARAMETER)[]". This example illustrates the "byrange" search type:
<form action={"/content/advancedsearch/"|ezurl} method="get"> <input type="hidden" name="Content_search_attribute_byrange_classattribute_id[]" value="42" /> <input type="text" name="Content_search_attribute_byrange_from[]" value="{$search_array_by_class_attribute_id['42']['from']}" /> <input type="text" name="Content_search_attribute_byrange_to[]" value="{$search_array_by_class_attribute_id['42']['to']}" /> <input type="submit" value="Search" name="SearchButton"> </form>
Log in or create a user account to comment.
Comments
Re: searching in several classes by attribute
Gunnstein Lye
Friday 13 October 2006 5:16:29 pm
searching in several classes by attribute
Helle Andersen
Friday 13 October 2006 4:34:00 pm
Re: Search based on attributes from two classes
Gunnstein Lye
Friday 13 October 2006 3:24:14 pm
Search based on attributes from two classes
Helle Andersen
Friday 13 October 2006 2:57:51 pm
I want to make a search box to search for the attribute "last name" in two specific classes (the identifier is the same in both classes).
Actually I would prefer a search box to seach both last name and/or first name in two specific classes (same identifier in both classes) but as I understand this, this is not possible ?
e.g. if you write Eric Hansen you get all the findes with Eric and all the finds with Hansen in the fields "first name" and "last name" in two specific classes
Helle
Re: So help me pls...
Gunnstein Lye
Monday 30 May 2005 9:30:11 am
I hope to make this more configurable in the future.
So help me pls...
Andrew Vorobyov
Sunday 29 May 2005 7:44:17 am
If you search by several attributes at once, you will only get results where all attributes match. In other words, only AND search is supported, not OR or NOT search.
=================
So please give me idea how make this kind OR or NOT search!