Forums / Developer / fetch content list with attribute filter
David Santiso
Thursday 07 April 2011 12:00:36 pm
Hi,
I want fetch content list with attribute filter, But the attribute I want to filter is an object relationship.
How can I do it?
Thanks,
David
Carlos Revillo
Friday 08 April 2011 12:09:56 am
Hi David.
If it is a object relation and no a object relation list, you can filter by the contentobject_id of the related object.
Example
attribute_filter( array( array( 'class/attr', '=', 60 ) )
beign 60 the object_id of the related object.
Friday 08 April 2011 9:55:57 am
'class/attr'? Is 'attr' the attribute name and is 'class' the class name?
I've put this:
{def $content=fetch( 'content', 'list', hash( 'parent_node_id', $filter, 'sort_by', array( 'published', false() ), 'attribute_filter', array( array( 'class_name/attribute_name', '=', 143 ) ) ) )}
Friday 08 April 2011 10:08:44 am
yes. that's it. you can use the id of the contentclassattribute_id instead if you prefer.
Friday 08 April 2011 10:52:24 am
Sorry, but I don't understand. When I put 'class_name/attribute_name':
'class_name' -> The class name containing the attribute.
'attribute_name' -> The class attribute (Object Relation).
'143' -> contentobject_id of referenced object.
Yes?
If so, doesn't work.
Friday 08 April 2011 11:00:27 am
yes. that's what i say. it should work like that. class_name/attribute_name is a object relation and no object_relation_list, right? if second then that won't work, but if it's the first, then it should...
Friday 08 April 2011 11:02:25 am
it could help if you enable your debug and sqloutput. after clearing caches and requesting your page, you should see all the queries needed for generating the page. one of them should be using that '143' somewhere...
maybe you can check that and see if debug says something about...
Saturday 09 April 2011 4:36:02 am
Yes, attribute_name is object_relation datatype and no object_relation_list.
How do I enable the sqloutput debug?
Monday 11 April 2011 11:33:47 am
I've activated debug sqloutput. Shows message: Attribute filter returns false
The identifier I'm using is one of the possible identifier objects that can be referenced by the attribute.
Tuesday 12 April 2011 11:03:44 am
My object_relation datatype is a selection list with the children of a folder class.
Can the problem be out there?
Denitsa M.
Friday 15 April 2011 5:23:15 am
-
Iguana IT - http://www.iguanait.com