Fewer than max nr of items show in section loop

Author Message

Vivienne van Velzen

Monday 27 October 2003 12:25:50 am

Hi,

I'm trying to show a maximum of 3 news articles that have their (self-defined) 'visible' flag on. This is my code:

{section name=News max=3 loop=fetch(...)}
{section-exclude match=$:item.data_map.visible.content|not()}
{$:item.name}<br>
{/section}

From the documentation I gathered that the iteration count will not be advanced if the loop item is discarded. In my output however, this is not the case.
For instance, I have the following newsitems:
Newsitem 1
Newsitem 2 (not visible)
Newsitem 3
Newsitem 4

My code only shows newsitems 1 and 3 (while I would have expected (and hoped) that 4 would also be shown).
Can anyone help?
TIA,

Vivienne

Arash Molavi

Tuesday 28 October 2003 5:09:31 am

Maybe you should hav "sort_by" in the fetch to?

Vivienne van Velzen

Tuesday 28 October 2003 6:02:03 am

I do have a sort_by in my fetch, but I'm under the impression that sort_by only influences the order in which items are shown, and not IF items are shown.
Can anyone back me up on this? And if I'm right, does someone else have a solution to my problem?

Ole Morten Halvorsen

Tuesday 28 October 2003 6:12:23 am

Hi

instead of using section-exclude, try this:

{section name=News max=3 loop=fetch(...)}
{section show=$:item.data_map.visible.content|not()}
{$:item.name}<br>
{/section}
{/section}

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Paul Forsyth

Tuesday 28 October 2003 6:18:55 am

I think you can fetch by class attribute:

http://ez.no/developer/ez_publish_3/documentation/development/libraries/ez_template/operators/data_fetch

and filter by value. With this you could also apply a 'limit' to the number of returned items.

Paul

Vivienne van Velzen

Tuesday 28 October 2003 6:36:49 am

Ole,

I've already tried the situation you're sketching, and that also shows two newsitems (in stead of three).
Thanks for the suggestion, though.

Paul,

I'll look into that. I thought that you couldn't fetch on self-defined attributes, but if you can....
I'll let you know if it worked.
Thanks,

Vivienne

Paul Borgermans

Tuesday 28 October 2003 6:46:34 am

Vivienne, the way Paul Forsyth suggests is the best and the only way to have exact 3 news items if 3 ore more are "visible".

---edited-----

I think you found a bug indeed (after reading the docs more closely)

-------------

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Vivienne van Velzen

Thursday 30 October 2003 12:57:04 am

Paul (Forsyth),

I tried your suggestion and it works like a charm! Thanks a lot.

Paul (Borgermans),

Well, since it seems I found a bug ( ;) ), I'll fill in a bug report.

Greetings,

Vivienne

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