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.