Share » Forums » Setup & design » fetch and ezenum

fetch and ezenum

fetch and ezenum

Tuesday 03 February 2004 10:51:43 am - 6 replies

Author Message

Albert Berenguer

Friday 06 February 2004 9:08:45 am

anybody? I need help please...
I am using eZ 3.3-3 at the moment.

the problem is that I want to fetch some items depending on an enum attribute value(named 'provincia'), I am now trying another way to do it but still haven't solve it: now what I do is fetch all the items and then copy the ones that I want into another array, and then loop through this array. The problem now is that i can't fins the way to copy the items to the new array, how can I do that?

I have previously fetched the items into $item_list and now I want to copy some of them using that code:
{let children=array()}
{section name=choosing loop=$item_list}
{ switch match=$choosing:item.data_map.provincia.content.enumobject_list.0.enumvalue }
{case match='anEnumValue' }
{ $children|append($item_list:item )}
{/case}
{/switch}
{/section}

any help please? thanks in advance

Tore Skobba

Friday 06 February 2004 9:45:55 am

Hmm I am just doing what you want to do, and I had the same error as you.. You must add an array in your fetch.. I.e

{let children=fetch( 'content', 'list', hash( parent_node_id, 74, attribute_filter, array( 506, '=', 'barcelona' ) ) ) }

Should be:

{let children=fetch( 'content', 'list', hash( parent_node_id, 74, attribute_filter, array(array(506, '=', 'barcelona') ) ) ) }

Does it work now?

BTW what is the difference between EZSelection and EZEnum???

Cheers
Tore

Albert Berenguer

Friday 06 February 2004 10:34:30 am

thanks for the reply Tore!!
I've tried the code you provided but it doesn't work :(, it returns all the items of the folder, like if I wasn't using the 'attribute_filter'.
I think the problem is the attribute being an enum, because I've tried to fetch with attribute_filter other types of attributes and it works properly.

I also tried using:
...attribute_filter, array('or',array(506, '=', 'barcelona'))
as I saw it in other forum messages and had also no success...

I hope someone of the ez crew could shed some light on that...

Thanks again
ALbert

Tore Skobba

Friday 06 February 2004 4:00:33 pm

Ahh yes... It is stored as a number, either you hardcode in the number for Barcelone or you fetch the class atribute and check the values there. I am home and I do not have my code available so can only do pseudo.

Debug out Barcelone content. Note the number and do:

(array(506, '=', 'BARCELONENUMBER') ) ) ) }

Or usally it is stored as this I belive
Option 1 0
Option 2 1
Option 3 2

So if Barcelone is the first then it is: (array(506, '=', '0')

Check this thread.
http://www.ez.no/community/forum/setup_design/ezselection_options_id_jumping_0_to_2_skipping_1_bug#msg44472

I.e. some times it is
Option 1 0
Option 2 2
Option 3 3

Skipping 1.

Cheers
Tore

Albert Berenguer

Monday 09 February 2004 10:49:36 am

hi again Tore...
i am really stuck in that...I have created a new attribute (an eZselection which id is 653) because I wasn't shure if it would work with eZenum or not.Then I've fetched the class attribute and the values are:
Barcelona - 0
Girona - 2
Lleida - 3
(see there's a jump between 0 and 2 as you reported, although I'm using 3.3-3)
and so, I tried the following code:
{let children=fetch( 'content', 'list', hash( parent_node_id, $node.node_id, attribute_filter, array( array( 653, '=', '0') ) ) ) }

but when the value to compare is '0' all the nodes are displayed, and no nodes are displayed when I change it to '2' or '3' (I must say I have one node of each possible value). I have no idea of what can be the problem, and debug doesn't give much information, the only strange thing in debug is:

"Undefined index: 653 in c:\archivos de programa\ez systems\ezpublish\kernel\classes\ezcontentobjecttreenode.php on line 419"

thanks for all the help provided till now Tore, I really have no idea of what to do, but I I'll continue trying :)

Albert Berenguer

Monday 09 February 2004 11:15:23 am

hi I did it!!
I don't know why it works but i found that in the file "sortkey_mysiteaccess.php" there wasn't a line with the number 653, so i added:

653 => "ezselection",

it didn't work so I tried another one:

653 => "ezstring",

and it worked properly!! I don't know why that file wasn't updated with all the attributes, and also don't know what does that file do, anybody knows? maybe some help will make me understand what was wrong.

Thanks again Tore!
Albert

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

36 542 Users on board!

Forums menu