Forums / Setup & design / Fetch only object with a selection-attribute specified?

Fetch only object with a selection-attribute specified?

Author Message

Daniele Nocentini

Wednesday 31 May 2006 6:49:36 am

Hi

I have a class with a three selection attributes. I want to fetch only nodes with that selection contain specific string. This would be my guess, but I'm not able to get it work:

{def $list_items=fetch( 'content', 'list', hash( 'parent_node_id', 138,
			  
              'class_filter_type',  'include',
              'class_filter_array', array(38),
			  'attribute_filter', array( 'and', array( 299, '=', 'Commerciale' ), array( 300, '=', 'Moto' ) ),
			   ) )}

Antica Bottega Digitale srl
http://www.abd.it

Marcin Drozd

Wednesday 31 May 2006 7:38:43 am

Hi Daniele
try with

{def $list_items=fetch( 'content', 'list', hash( 'parent_node_id', 138,
             'class_filter_type', 'include',
             'class_filter_array', array(38),
                         'attribute_filter', array( 'and', array( 299, '=', 'Commerciale' ), array( 300, '=', 'Moto' ) )
                          ) )}

without "," after 'Moto' ) ) :)

http://ez-publish.pl

Daniele Nocentini

Wednesday 31 May 2006 12:37:29 pm

The question is, can attribute_filter works with selection datatype (with multiple selection choice)?

Antica Bottega Digitale srl
http://www.abd.it

Marcin Drozd

Wednesday 31 May 2006 2:48:08 pm

Hi, I got it wrong, sorry

can attribute_filter works with selection datatype?

Yes, it is possible, but U should use:

'attribute_filter', array( array( 299, '=', VALUE ) )

where VALUE starts from 0.
(with selection datatype (with single choice, I never tested with multiple) options have value from 0)

ex. for

<select name="aaa">
<option value="0">Commerciale 1</option>
<option value="1">Commerciale 2</option>
<option value="2">Commerciale</option>
</select>

use:

(for string 'Commerciale') 'attribute_filter', array( array( 299, '=', 2 ) ) or better
'attribute_filter', array( array( 299, '=', ezhttp( 'aaa', 'post' ) ) )

http://ez-publish.pl