Forums / Setup & design / attribute_filter doesn't work

attribute_filter doesn't work

Author Message

Oliver Dzierzon

Friday 30 January 2009 10:29:40 am

I extended the article class by adding the attribute 'possition' (datatype: select).
I did this because I have to define in which of three columns the created object should be placed.

in my design template i have to examine whether there is an article which I have to place in column1. therefore i use this code


{def $contlist = fetch('content',
	'list_count',
	hash('parent_node_id', 2, 
		'class_filter_type', 'include',
		'class_filter_array', array('article_standard'),
		'attribute_filter', array(
			array('article_standard/position','=','column1'),
		)
         )
)
}

Although I have placed an article of the class 'article_standard' under the parent node 2
into Column1, the output of $contlist is 0.

Leaving the attribute filter away:

 {def $contlist = fetch('content',
	'list_count',
	hash('parent_node_id', 2, 
		'class_filter_type', 'include',
		'class_filter_array', array('article_standard'),
		
         )
)
}

In this case code results the expected 1. What is my mistake?

ciao Olli

Greg McAvoy-Jensen

Friday 30 January 2009 10:41:33 am

Oliver,

Instead of 'column1', try the value of 0. I don't think one can search by the descriptive text of a select option; only by a number representing its order in the select option list (beginning, I think, with 0).

Granite Horizon, Certified Developer of eZ Publish Web Solutions
Provider of the SaaS Solution Granite Horizon In The Cloud | http://granitehorizon.com/cloud
http://granitehorizon.com | +1 916 647 6350 | California USA | @granitegreg
Blog: http://granitehorizon.com/blog

Oliver Dzierzon

Saturday 31 January 2009 2:42:27 pm

Thank you. You're right. I changed the code to:

{def $contlist = fetch('content',
	'list_count',
	hash('parent_node_id', 2, 
		'class_filter_type', 'include',
		'class_filter_array', array('article_standard'),
		'attribute_filter',array('and',
			array('article_standard/position','=',0),
			array('article_standard/title','like','*Test*')
		)
	)
)}

and now it works.

ciao Olli