Share » Forums » Setup & design » fetch with attribute_filter on a...

fetch with attribute_filter on a multi selection datatype

fetch with attribute_filter on a multi selection datatype

Wednesday 27 October 2010 2:27:38 am - 7 replies

Author Message

Ivo Lukac

Wednesday 27 October 2010 4:24:14 am

Hi,

IMO you can't use 'attribute_filter' more then once. Either build your own 'extended_attribute_filter' or try using ezfind fetch...

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

nicholas king

Wednesday 27 October 2010 6:03:40 am

Hello Ivo,

thanks for the reply.

ignoring the fact that i am using attribute_filter, do you know how to do the filter on a multi selection

Thanks

Nicholas

Heath

Wednesday 27 October 2010 6:59:37 am

Hello Nicolas King,

You can do what you want but it must be formatted differently. I haven't tested this but I think it's more accurate.

{def $var = 3}  {def $tasking=fetch( 'content','list', hash( 'parent_node_id', 517, 'class_filter_type', 'include', 'class_filter_array', array('tasking'), 'attribute_filter', array( array( 'tasking/completed', '!=', 1 ), array( 'tasking/tasking_area', 'like', $var ) ),
'limit', 150 ) )}

There is an example of doing this at ezpedia,

http://ezpedia.org/solution/how_to_fetch_content_based_on_view_parameter_date_range

Cheers,

Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

nicholas king

Wednesday 27 October 2010 7:11:13 am

Hello Heath,

Thanks for your reply,

You're code seems to still bring back everything, but it seems like im a step forward to solving this problem.

Thanks again

Nicholas

nicholas king

Thursday 28 October 2010 1:31:32 am

The code that heath has provided will do a fetch provided that the multi select attribute has only one option selected. If more than one option is selected then the fetch returns nothing.

the way ez stores the options selected in the multi select is in the form of a index to the selected elements with a hyphon seperating the options ie.

0-1-4-6

at first glance this would suggestdoing a like along the lines of this...

{set $children_count=fetch_alias( 'children_count', hash( 'parent_node_id', 517,
'class_filter_type','include',
'class_filter_array', array('tasking'),
'attribute_filter', array(array('tasking/completed', '!=', 1)),
'attribute_filter', array('or', array('tasking/tasking_area','like',$area_code),array('tasking/tasking_area','like','*-'.$area_code),array('tasking/tasking_area','like',$area_code.'-*'),array('tasking/tasking_area','like','*-'.$area_code.'-*')) ))}

however this also does not work...

any other ideas?

nicholas king

Friday 29 October 2010 5:21:49 am

Right i have also had a look at doing this through object relations but cant get this fetch to work through object relations either,

has anyone got any experience of creating 1 to many relationships in the fetch.

ie

one post having 0 to many categories and then doing a fetch to seeing if a post has a particular category in it.

Thanks

Nicholas

nicholas king

Monday 01 November 2010 6:45:22 am

Hello all,

I have also tryed looking into doing this with extended attribute filter on the object relation,

has anyone got this to work.

Thanks

Nicholas

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu