Forums / General / Fetch class with changing attribute filter parameters

Fetch class with changing attribute filter parameters

Author Message

Kristoffer Raun

Sunday 01 October 2006 6:19:24 am

Hi

I'm trying to fetch all class 19.
In my class i have a single selection drop down box, where one can select between 15 different options.
For each option there can be several documents where the option has been selected.
I want to fetch the data corresponding to selection 0 first (prehaps several objects), then commence to selection 1, and so on.

This is my problem part:

{section loop=fetch('content','list',hash(parent_node_id,$node.node_id,class_filter_array,array(19),'sort_by', array( 'published', false() ) ,'attribute_filter', array(array( 'rekordfisk/fiskeart_rekord', '=', '$num:index' ))))}

I have defined $num:index as a inc. number, from 0 to 14 and i want to fetch all the objects of the class 19 with eg. selection 0, then selection 1 and so on

My code should do the following
Fetch all class 19 with selection 0 on, sorted by publishing date
Fetch all class 19 with selection 1 on, sorted by publishing date
Fetch all class 19 with selection 2 on, sorted by publishing date
.............

does the explanation makes sense? (I'm affraid it's a bit unclear)

full code below:

Thanks in advance

{let fiskclass=fetch('content','list',hash(parent_node_id,$node.node_id,class_filter_array,array(19)))}

{section  name=num loop=15}
{$num:index}

{let fishnew=1}
{let fishold=1}
{section loop=fetch('content','list',hash(parent_node_id,$node.node_id,class_filter_array,array(19),'sort_by', array( 'published', false() ) ,'attribute_filter', array(array( 'rekordfisk/fiskeart_rekord', '=', '$num:index' ))))}

{switch match=$num:fishnew}
	{case match=1}

<b>{attribute_view_gui attribute=$:item.object.data_map.fiskeart_rekord}</b><br>
Fisken vejede: {attribute_view_gui attribute=$:item.object.data_map.fiskevaegt_rekord} kg.<br>
Længden af fisken: {attribute_view_gui attribute=$:item.object.data_map.fiskelaengde_rekord} cm.<br>
Fanget af: {attribute_view_gui attribute=$:item.object.data_map.fiskeuvnavn_rekord}<br><br>
{set fishnew=2}
	{/case}
	
	{case match=2}
		
{switch match=$num:fishold}
	{case match=1}
	De(n) gamle rekord(er) var:<br>
{attribute_view_gui attribute=$:item.object.data_map.fiskeuvnavn_rekord}, {attribute_view_gui attribute=$:item.object.data_map.fiskevaegt_rekord} kg., {attribute_view_gui attribute=$:item.object.data_map.fiskelaengde_rekord} cm.<br>
{set fishold=2}
	{/case}
	
	{case match=2}
	
{attribute_view_gui attribute=$:item.object.data_map.fiskeuvnavn_rekord}, {attribute_view_gui attribute=$:item.object.data_map.fiskevaegt_rekord} kg., {attribute_view_gui attribute=$:item.object.data_map.fiskelaengde_rekord} cm.<br>

	{/case}

{/switch}


	{/case}

{/switch}

{/section}
--------------------------------------------<br>
{/let}
{/let}
{/section}
{/let}

<i>If you can't describe what you are doing as a process, you don't know what you're doing.</i>
W. Edwards Deming

Xavier Dutoit

Sunday 01 October 2006 7:57:19 am

Not sure what you want to do, but have a look at the enhanced object relation contrib,

http://ez.no/community/contribs/datatypes/enhanced_objectrelation

With the reverse relation fetch, you can get all the objects that have selected a specific item.

X+

http://www.sydesy.com