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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 04:05:07
Script start
Timing: Jan 18 2025 04:05:07
Module start 'layout'
Timing: Jan 18 2025 04:05:07
Module start 'content'
Timing: Jan 18 2025 04:05:08
Module end 'content'
Timing: Jan 18 2025 04:05:08
Script end

Main resources:

Total runtime1.1888 sec
Peak memory usage4,096.0000 KB
Database Queries67

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0083 587.9141152.6250
Module start 'layout' 0.00830.0037 740.539139.4609
Module start 'content' 0.01201.1753 780.0000668.4688
Module end 'content' 1.18730.0015 1,448.468816.1641
Script end 1.1888  1,464.6328 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2724160.0002
Check MTime0.00130.1103160.0001
Mysql Total
Database connection0.00080.070510.0008
Mysqli_queries1.114693.7577670.0166
Looping result0.00080.0698650.0000
Template Total1.151396.820.5757
Template load0.00220.187020.0011
Template processing1.149196.655520.5745
Template load and register function0.00010.009310.0001
states
state_id_array0.00100.085010.0010
state_identifier_array0.00130.108020.0006
Override
Cache load0.00190.1614450.0000
Sytem overhead
Fetch class attribute can translate value0.00070.060940.0002
Fetch class attribute name0.00140.115890.0002
XML
Image XML parsing0.00220.186540.0006
class_abstraction
Instantiating content class attribute0.00000.0020100.0000
General
dbfile0.00140.1216350.0000
String conversion0.00000.001040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 38
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs