Philippe VINCENT-ROYOL
|
Wednesday 09 January 2008 6:08:53 am
Hi, I've a problem with a fetch function.. I want to concat this two lines but it does nt work ..
$children=fetch( 'content', 'tree', hash( 'parent_node_id',$metiers_node.node_id, 'sort_by',array( 'name', true()), 'class_filter_type','include',
'class_filter_array',array( 'job', 'chained_article' ), 'attribute_filter', array( array('job/title' ,'like', $montitre) ) ) )
$children=fetch( 'content', 'tree', hash( 'parent_node_id',$metiers_node.node_id, 'sort_by',array( 'name', true()), 'class_filter_type','include',
'class_filter_array',array( 'job', 'chained_article' ), 'attribute_filter', array( array('chained_article/title' ,'like', $montitre) ) ) ) It work when i use only the first or the second.. But when i try:
$children=fetch( 'content', 'tree', hash( 'parent_node_id',$metiers_node.node_id, 'sort_by',array( 'name', true()), 'class_filter_type','include',
'class_filter_array',array( 'job', 'chained_article' ), 'attribute_filter', array( 'or', array('job/title' ,'like', $montitre), array('chained_article/title', 'like', $montitre) ) ) ) They are no answer :/ What i m doing wrong? Thanks
Certified Developer (4.1): http://auth.ez.no/certification/verify/272607
Certified Developer (4.4): http://auth.ez.no/certification/verify/377321
G+ : http://plus.tl/dspe
Twitter : http://twitter.com/dspe
|
Philippe VINCENT-ROYOL
|
Wednesday 09 January 2008 6:47:50 am
ive found a solution:
$children1=fetch( 'content', 'tree', hash( 'parent_node_id',$metiers_node.node_id, 'sort_by',array( 'name', true()), 'class_filter_type','include',
'class_filter_array',array( 'job', 'chained_article' ),
'attribute_filter', array( array('job/title' ,'like', $montitre) ) ) )
$children2=fetch( 'content', 'tree', hash( 'parent_node_id',$metiers_node.node_id, 'sort_by',array( 'name', true()), 'class_filter_type','include',
'class_filter_array',array( 'job', 'chained_article' ),
'attribute_filter', array( array('chained_article/title' ,'like', $montitre) ) ) )
$children=merge($children1, $children2) And it works.. Thanks.
Certified Developer (4.1): http://auth.ez.no/certification/verify/272607
Certified Developer (4.4): http://auth.ez.no/certification/verify/377321
G+ : http://plus.tl/dspe
Twitter : http://twitter.com/dspe
|
André R.
|
Wednesday 09 January 2008 9:48:57 am
The correct thing would be (using code tags so others even bother reading you code..):
{def $children1 = fetch( 'content', 'tree', hash(
'parent_node_id', $metiers_node.node_id,
'sort_by', array( 'name', true()),
'class_filter_type', 'include',
'class_filter_array', array( 'job' ),
'attribute_filter', array( array('job/title' ,'like', $montitre) )
) )
$children2 = fetch( 'content', 'tree', hash(
'parent_node_id', $metiers_node.node_id,
'sort_by', array( 'name', true()),
'class_filter_type', 'include',
'class_filter_array', array( 'chained_article' ),
'attribute_filter', array( array('chained_article/title' ,'like', $montitre) )
) )
$children = merge( $children1, $children2 )}
Heath: It's true that attribute filter will effectively filter classes as well, but index wise I think using a class filter as well is faster on large dataset. But this depend on the indexes on the ezcontentobject_attribute table, haven't looked at it for a while.
Ref:
http://pubsvn.ez.no/nextgen/trunk/kernel/classes/ezcontentobjecttreenode.php Search for "function createAttributeFilterSQLStrings".
eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom
|
Piotr Switkowski
|
Sunday 03 February 2008 1:51:21 pm
Well, doing two separate fetches and merging results is not the same thing as doing one fetch. The real difference is performance. Let assume, you implemented paging on your website. With single fetch you need to retrieve only few objects for one page. With two fetches and merging you need to retrieve all fitting objects. Also, with merging you cannot sort in database. If you want the result sorted, you need to sort in your template code. All in all, I cannot understand, why attribute_filter is not supporting attribute filtering on attributes from different classes with 'or'. Should this be registered as ezPublish bug?
|