Attribute Filter in Fetch Function

Author Message

Bayron Guevara

Friday 07 December 2007 7:49:33 am

Hello!
I have a problem when I want to fetch nodes , filtering by a related object attribute, I don´t know what to write in the comparison. The code is following:

    {def $secc_rel = $node.data_map.seccion_relacionada}

     {***Extrae una lista de las noticias de esta seccion para el dia especificado***}
     {def $noticias = fetch('content', 'list', hash('parent_node_id', $nodo_edicion.node_id,
								 'attribute_filter', array( array('noticia_principal/seccion_relacionada', '=', $secc_rel) ) ) )}

Web Developer & Modern Philosopher
Visit http://www.laprensa.hn, http://www.diez.hn, http://www.estilo.hn

Paul Leclercq

Friday 07 December 2007 10:30:49 am

Hello Bayron,

It isn't possible to use attribute_filters for fetch 'lists' of ObjectRelationLists:
http://ez.no/developer/forum/setup_design/objectrelationlist_and_attribute_filter

So if you have more than one object related to your object then you will need to find another solution:

That way you can maybe try using an operator and use this function:
http://pubsvn.ez.no/doxygen/trunk/html/classeZContentObjectTreeNode.html

 $node_array =& eZContentObjectTreeNode::subTree(
        array( 'Depth' => 1,
               'Limit'            => 50,
               'Offset'           => 0,
               'SortBy'           => array( 'published', 1 ),
               'DepthOperator'    => 'eq',
               'ClassFilterType'  => 'include',
               'ClassFilterArray' =>  array('comment')
               ), $nodeID );

Function which works in a similar way as fetch('content', 'list' ....
You can then try and filter your results related attributes or order them using classic php functions.

Nicolas Lescure

Friday 07 December 2007 12:08:08 pm

I use this on eZ 3.9.2 :
http://ez.no/developer/contribs/datatypes/enhanced_objectrelation (<b>download the svn version :</b>
http://pubsvn.ez.no/community/trunk/extension/enhancedobjectrelation)

Then you'll need an extended attribute filter to use it.

Which version of eZ do you use ?
If your eZ is not a 3.9.10 you'll have to make a little hack for the kernel to add a "distinct" in the query generated.

Bayron Guevara

Monday 10 December 2007 7:26:42 am

Hello, Paul Leclercq.
Thank you for your collaboration, but I want to filter a <i>unique</i> related object, which is permitted.
See bellow:

Filtering on the attribute level is supported for the following datatypes:
• Checkbox
• Date
• Date and time
• E-mail
• Integer
• <b>Object relation</b>
• Selection (will not work when used as multiple selector)
• Text line
• Time

Again, How can I do a single related object filter?

Something more, I was reading the class code than you suggest me, I think than its parameters are similiar to fetch function, except than it uses php code, I am in the right thing?

Web Developer & Modern Philosopher
Visit http://www.laprensa.hn, http://www.diez.hn, http://www.estilo.hn

Paul Leclercq

Tuesday 11 December 2007 1:13:10 am

You need to make sure you have the correct datatype, an object relation List returns an array of objects while an Object Relation Returns a single Object, not only make sure you have one object. You can make sure you have the correct datatype while editing your class in the administration interface->administration->class.

You should then be able to use the attribute_filters in the same way as for other types of attributes, other examples are shown on this page:
http://ez.no/doc/ez_publish/technical_manual/3_9/reference/modules/content/fetch_functions/list

'attribute_filter', array( 'or',
                                        array( 152, '=', 'abc' ),
                                        array( 153, '=', '42' ) 

The php code I gave out, is indeed, to create a custom fetch function by using an operator with php code. Although I read yesterday that it was no longer possible to use the static version of subtree() in ez4:
http://serwatka.net/index.php/en/blog/ez_publish_4_0_post_release_notes

Bayron Guevara

Tuesday 11 December 2007 2:49:51 pm

Paul, the datatype than I'm utilizing is <i>Object Relation</i>, no a Object Relation list. The examples than you give me a link, don't include this datatype. Thank you for your help, but I still don't found a simple solution.

Web Developer & Modern Philosopher
Visit http://www.laprensa.hn, http://www.diez.hn, http://www.estilo.hn

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 16:08:45
Script start
Timing: Jan 18 2025 16:08:45
Module start 'layout'
Timing: Jan 18 2025 16:08:45
Module start 'content'
Timing: Jan 18 2025 16:08:46
Module end 'content'
Timing: Jan 18 2025 16:08:46
Script end

Main resources:

Total runtime0.7366 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 587.9219152.6250
Module start 'layout' 0.00560.0024 740.546939.4609
Module start 'content' 0.00800.7271 780.0078637.4531
Module end 'content' 0.73510.0015 1,417.460920.1563
Script end 0.7366  1,437.6172 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4640160.0002
Check MTime0.00150.2077160.0001
Mysql Total
Database connection0.00080.107510.0008
Mysqli_queries0.666890.5243680.0098
Looping result0.00070.0888660.0000
Template Total0.709296.320.3546
Template load0.00240.325420.0012
Template processing0.706895.948420.3534
Template load and register function0.00010.011810.0001
states
state_id_array0.00090.126910.0009
state_identifier_array0.00080.107020.0004
Override
Cache load0.00210.2896450.0000
Sytem overhead
Fetch class attribute can translate value0.00050.065630.0002
Fetch class attribute name0.00090.128390.0001
XML
Image XML parsing0.00490.665930.0016
class_abstraction
Instantiating content class attribute0.00000.0035120.0000
General
dbfile0.00460.6187280.0002
String conversion0.00000.000940.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
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
13content/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: 40
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs