Strange fetch error in EZ 4

Author Message

H. K.

Friday 07 March 2008 1:34:22 am

In EZ publish 4.0 I have stumbled upon a strange error when fetching a multi class front page folder.

I currently use this code to fetch a video section on the front page.

{def $video1=fetch( content, tree, hash( parent_node_id, 2,
                                         limit, 1,

                                         sort_by, array( published, false() ),

                                         'class_filter_array', array( 37 ),

                                          ) )}
{foreach $video1 as $vid1}


<div class="video1">
<div class="child">
<a href={$vid1.data_map.url.content|ezurl()}>
{attribute_view_gui attribute=$vid1.data_map.image image_class=videoremote}


{$vid1.name|wash}
</a>

</div>
</div>

{/foreach}

{undef $video1}

The code works, but when I publish a article and the front page is updated the video sections not longer works.

Output
No relation + Name of article (should not be there, since it’s not supposed to be fetch!!!)

When I clear all the case the problem remains, but when I publish a new video the section works again.

In my page I mainly use let not def, is this a likely cause of the problem or is it a bug?

H. K.

Thursday 13 March 2008 9:12:40 am

Since there have been no inputs, the error has been reported as a bug.

Hans Melis

Thursday 13 March 2008 10:24:15 am

You are using 'class_filter_array', but you haven't specified 'class_filter_type'. Without the type of class filtering, the filter array won't be used at all. The possible values for the type are 'include' and 'exclude'.

Use 'include' to restrict the fetch to objects of the content classes specified in the filter array. Use 'exclude' to fetch all objects except those of the content classes specified in the filter array.

So basically, all you do now is fetching the most recently published node instead of the most recently published video.

And do you have any special reason to use a foreach? It's not wrong of course, but you are limiting the fetch to 1 result so it's a bit of a waste to loop. You can also access the first element of an array by using an index, e.g. $video1[0].

Hans
http://blog.hansmelis.be

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 14:55:42
Script start
Timing: Jan 18 2025 14:55:42
Module start 'layout'
Timing: Jan 18 2025 14:55:42
Module start 'content'
Timing: Jan 18 2025 14:55:42
Module end 'content'
Timing: Jan 18 2025 14:55:42
Script end

Main resources:

Total runtime0.0218 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0094 587.9063152.6250
Module start 'layout' 0.00940.0025 740.531339.4453
Module start 'content' 0.01190.0075 779.976689.4141
Module end 'content' 0.01940.0023 869.390634.3047
Script end 0.0217  903.6953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.004118.6477140.0003
Check MTime0.00135.8666140.0001
Mysql Total
Database connection0.00042.039110.0004
Mysqli_queries0.005324.160630.0018
Looping result0.00000.054810.0000
Template Total0.00157.110.0015
Template load0.00073.399310.0007
Template processing0.00083.698210.0008
Override
Cache load0.00052.338110.0005
General
dbfile0.002410.887780.0003
String conversion0.00000.037240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs