Forums / Setup & design / fetch and ezenum

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

eZ debug

Timing: Jan 18 2025 15:54:15
Script start
Timing: Jan 18 2025 15:54:15
Module start 'content'
Timing: Jan 18 2025 15:54:15
Module end 'content'
Timing: Jan 18 2025 15:54:16
Script end

Main resources:

Total runtime0.7868 sec
Peak memory usage4,096.0000 KB
Database Queries206

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 587.6094180.8438
Module start 'content' 0.00620.6498 768.4531540.6563
Module end 'content' 0.65600.1307 1,309.1094341.8125
Script end 0.7868  1,650.9219 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.5074210.0002
Check MTime0.00150.1869210.0001
Mysql Total
Database connection0.00140.174910.0014
Mysqli_queries0.706389.76542060.0034
Looping result0.00190.24122040.0000
Template Total0.760496.620.3802
Template load0.00190.245820.0010
Template processing0.758496.390320.3792
Template load and register function0.00010.016810.0001
states
state_id_array0.00070.085910.0007
state_identifier_array0.00100.133220.0005
Override
Cache load0.00170.2187820.0000
Sytem overhead
Fetch class attribute can translate value0.00130.161030.0004
Fetch class attribute name0.00130.163370.0002
XML
Image XML parsing0.00050.068030.0002
class_abstraction
Instantiating content class attribute0.00000.001970.0000
General
dbfile0.00720.9111210.0003
String conversion0.00000.003130.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 41
 Number of unique templates used: 5

Time used to render debug report: 0.0002 secs