How to use class_attribute_id in ezfind

Author Message

kingsun he

Tuesday 07 September 2010 12:20:27 am

I use the search function of ezpublish like

{def
$search=fetch( 'content', 'search',
hash( 'text',$search_text,
'class_id', 22,
'section_id',6,
'class_attribute_id',202,
'sort_by',array( 'attribute',
true(),
'product/title' ),
'offset',$view_parameters.offset,
'limit',$page_prod_limit
) )
$search_prod_result = $search['SearchResult']
$search_prod_count=$search['SearchCount']
}

But now I want to use the ezfind to search, the code should be

{def
$search_text = ezhttp( 'SearchText','get')
$page_prod_limit=5

$search = fetch( ezfind,search,
hash( 'query', $search_text,
'class_id', 22,
'section_id',6,
'sort_by', hash( 'product/title_web', 'asc' ),
'offset',$view_parameters.offset,
'limit',$page_prod_limit

))
$search_prod_result = $search['SearchResult']
$search_prod_count=$search['SearchCount']
}

How can I use the class_attribute_id filter in the code for ezfind ? anybody help me ?

Matthieu Sévère

Tuesday 07 September 2010 12:33:35 am

This indeed the way to go, you should have a look here : http://ez.no/doc/extensions/ez_find/2_2/customization/template_fetch_functions

You can also use filter mechanism to restrict the search to a content_class

--
eZ certified developer: http://ez.no/certification/verify/346216

kingsun he

Tuesday 07 September 2010 1:59:35 am

I have found the solution with the help

The code should be:

{def
$search_text = ezhttp( 'SearchText','get')
$page_prod_limit=5

$search = fetch( ezfind,search,
hash( 'query', '',
'class_id', 22,
'section_id',6,
'filter', concat('product/title_web:', $search_text),
'sort_by', hash( 'product/title_web', 'asc' ),
'offset',$view_parameters.offset,
'limit',$page_prod_limit
))

$search_prod_result = $search['SearchResult']
$search_prod_count=$search['SearchCount']
}

And Change the DatatypeMap[ezstring]=string to DatatypeMap[ezstring]=text in ezfind.ini. update the index again.

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