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.

eZ debug

Timing: Jan 30 2025 19:47:37
Script start
Timing: Jan 30 2025 19:47:37
Module start 'layout'
Timing: Jan 30 2025 19:47:37
Module start 'content'
Timing: Jan 30 2025 19:47:37
Module end 'content'
Timing: Jan 30 2025 19:47:37
Script end

Main resources:

Total runtime0.0238 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0043 588.2813151.2266
Module start 'layout' 0.00430.0041 739.5078220.7188
Module start 'content' 0.00840.0141 960.2266998.9766
Module end 'content' 0.02250.0013 1,959.203133.9922
Script end 0.0238  1,993.1953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002510.4974140.0002
Check MTime0.00104.2526140.0001
Mysql Total
Database connection0.00062.397610.0006
Mysqli_queries0.002711.204230.0009
Looping result0.00000.046110.0000
Template Total0.00104.310.0010
Template load0.00083.552910.0008
Template processing0.00020.684710.0002
Override
Cache load0.00062.501710.0006
General
dbfile0.00135.534080.0002
String conversion0.00000.034040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs