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.