Forums / Setup & design / Custom advanced search question

Custom advanced search question

Author Message

Roberto Frascarelli

Monday 07 March 2005 2:42:17 am

Hi all,
I have a custom class "Announce" with a category (single selection) attribute and some other searchable contents.

I want to implement a custom search on those objects with two search fields: one text field for text search and one selectbox with category selection.

I know how to use "SearchContentClassAttributeID" field to limit the searched text to a single attribute, but what I want is to limit the search results of the searched text to objects that have a specific category value.

I can't find the way to use advanced search to obtain this in one step.
The only way I founded is to filter the results after the search, but this is not very efficient.

Thanks in advance for suggestions.

Ɓukasz Serwatka

Monday 07 March 2005 10:20:05 pm

Hi Roberto,

Maybe some of this information will be useful for you.
http://ez.no/community/bugs/search_lacks_multi_attribute_queries

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Yelitza Jaramillo

Thursday 10 March 2005 1:11:12 am

Hi Roberto,

If you want to narrow your search results by some specific attributes, you can do so making use of the advancesearch module and overriding the template "/standard/templates/content/advancesearch.tpl", you need to fill the array "Content_search_attribute...." with the new search requirements. Here is an example, i have a class "Studium" with this attributes : name (text line), poeng (text line) and varighet (text line). I want to set a customized advanced search where the search is done only in the object with an specific varighet (lets say the id for this attribute is 195), the form in my template looks like this :

<form method="get" action={'/content/advancedsearch'|ezurl}>
<input type="text" name="SearchText" value="{$full_search_text}" >
Varighet:
<input type="hidden" name="Content_search_attribute_fulltext_classattribute_id[]" value="195" />
<input type="text" name="Content_search_attribute_fulltext_value[]"               value="{$search_array_by_class_attribute_id['195']['value']}" />
<input type="submit"  value="Search" name="SearchButton">

As you can see, after one search is done, you get the values entered before in the array "$search_array_by_class_attribute_id".

You can also narrow the search using ranges

Age:
<input type="hidden" name="Content_search_attribute_byrange_classattribute_id[]" value="400" />
From:<input type="text" name="Content_search_attribute_byrange_from[]" value="" />
To: <input type="text" name="Content_search_attribute_byrange_from[]" value="">

 

Or if you are searching in an attribute of the integer type:

Age:
<input type="hidden" name="Content_search_attribute_integer_classattribute_id[]" value="400" />
<input type="text" name="Content_search_attribute_integer_value[]" value="" />

 

Hope this helps.

Roberto Frascarelli

Thursday 10 March 2005 5:42:06 am

Thanks Yelitza,
you have been very useful with your clarifying example.

My custom search works well now.
This is my code :


<form action={"/content/advancedsearch"|ezurl} method="get">
  <div whitespace=nowrap>
 <b>Find in announces :</b> <input type="text" id="searchtext" name="SearchText" size="25">
   <input type="hidden" name="Content_search_attribute_fulltext_classattribute_id[]" value="320" />
    Category: <select name="Content_search_attribute_fulltext_value[]">
                 <option value=""></option>
                 <option value="Deliberations">Deliberations</option>
                 <option value="Regulations">Regulations</option>
                 <option value="Various">Various</option>
               </select>
     <input id="searchbutton" class="button" name="SearchButton" type="submit" value="Search" />
   </div>
  <input type="hidden" name="SubTreeArray" value="169"  />
  <input type="hidden" name="SearchContentClassID" value="42"  / >
</form>

Some of your examples should have to be inserted under the documentation pages,
perhaps adding an "attribute value search" here:
http://www.ez.no/ez_publish/documentation/customization/components/search/custom_search_box

Gunnstein Lye

Wednesday 16 March 2005 7:50:57 am

Hi,

I added a description of the attribute based search here:
http://ez.no/ez_publish/documentation/customization/components/search/custom_search_box