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.

eZ debug

Timing: Jan 31 2025 09:34:48
Script start
Timing: Jan 31 2025 09:34:48
Module start 'layout'
Timing: Jan 31 2025 09:34:48
Module start 'content'
Timing: Jan 31 2025 09:34:48
Module end 'content'
Timing: Jan 31 2025 09:34:48
Script end

Main resources:

Total runtime0.0208 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.0073 588.2656151.2266
Module start 'layout' 0.00730.0032 739.492236.6953
Module start 'content' 0.01040.0084 776.187598.1875
Module end 'content' 0.01880.0020 874.375037.9922
Script end 0.0208  912.3672 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.003114.8013140.0002
Check MTime0.00115.4512140.0001
Mysql Total
Database connection0.00104.844010.0010
Mysqli_queries0.003315.752230.0011
Looping result0.00000.085910.0000
Template Total0.00125.610.0012
Template load0.00094.282610.0009
Template processing0.00031.244210.0003
Override
Cache load0.00062.945610.0006
General
dbfile0.003516.829280.0004
String conversion0.00000.067640.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