fetch and ezenum

Author Message

Albert Berenguer

Tuesday 03 February 2004 10:51:43 am

hi,
i have a simple question: does fetch support filtering by an ezenum attribute? I have the following code which doesn't work:

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

where the attribute with id 506 is an ezenum. Maybe the problem is that the possible values of the enum are strings?

I found a bug report about that topic(http://ez.no/community/bug_reports/attribute_filter_with_eznum), the reply is a bit discouraging...

if its not supported, is there any other way to do it?
thanks in advance

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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:18:40
Script start
Timing: Jan 18 2025 16:18:40
Module start 'layout'
Timing: Jan 18 2025 16:18:40
Module start 'content'
Timing: Jan 18 2025 16:18:41
Module end 'content'
Timing: Jan 18 2025 16:18:41
Script end

Main resources:

Total runtime0.7814 sec
Peak memory usage4,096.0000 KB
Database Queries69

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0114 587.8125152.6094
Module start 'layout' 0.01140.0036 740.421939.4141
Module start 'content' 0.01500.7654 779.8359535.5938
Module end 'content' 0.78040.0011 1,315.429716.1875
Script end 0.7814  1,331.6172 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.4396160.0002
Check MTime0.00150.1884160.0001
Mysql Total
Database connection0.00290.371710.0029
Mysqli_queries0.712291.1327690.0103
Looping result0.00060.0776670.0000
Template Total0.737394.320.3686
Template load0.00260.328020.0013
Template processing0.734794.020020.3674
Template load and register function0.00020.020010.0002
states
state_id_array0.00190.237610.0019
state_identifier_array0.00110.136320.0005
Override
Cache load0.00230.2988820.0000
Sytem overhead
Fetch class attribute can translate value0.00070.095120.0004
Fetch class attribute name0.00080.107470.0001
XML
Image XML parsing0.00020.028420.0001
class_abstraction
Instantiating content class attribute0.00000.001570.0000
General
dbfile0.00160.2102100.0002
String conversion0.00000.001640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
15content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
17content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 41
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs