Efficient changing of {section} output

Author Message

Tristan Koen

Thursday 24 July 2003 1:17:16 am

Hi

I have a page where I fetch() a number of records from a folder. When displaying these records in a section, I want to display the first one differently. What is the most efficient way to do this.
I am using the following code: (it works fine, but seems a bit of a kludge)

<h2>{$node.name|wash}</h2>
{let news_cats=fetch('content',list,hash(parent_node_id,$node.node_id,limit,3))}
{section name=News loop=$news_cats max=1}
<h3><a href={concat('content/view/full/',$News:item.node_id)|ezurl}>{$News:item.data_map.title.content}</h3></a>
<div>{$News:item.data_map.intro.content.output.output_text}</div>
<br />
{/section}
{section name=News2 loop=$news_cats offset=1}
<h3><a href={concat('content/view/full/',$News2:item.node_id)|ezurl}>{$News2:item.data_map.title.content}</h3></a>
<br />
{/section}
{/let}
<a href={concat('content/view/full/',$node.node_id)|ezurl}>[ Read more articles... ]</a>

Thanks

Tristan

Jan Borsodi

Thursday 24 July 2003 1:26:00 am

You could use one 'section' to loop trough the items and then another one to check for that specific first item.
{section loop=$new_cats}
<h3><a...></a></h3>
{section show=eq($:index,0)}
<div>...</div>
{/section}
{/section}

'index' is a variable generated by the section when it loops, it start at 0 and increases as each item is processed.
A 'number' variable is also available which starts at 1 and increases.

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Tristan Koen

Friday 25 July 2003 12:29:59 am

Ah! Thanks. Thats exactly what I was looking for. In my initial attempts I was trying
{section show=eq($news_cats.1,0)}
...
{/section}
which didn't work at all. I have to assume that the fetch('content',line,hash(....)) function doesn't return an array then? Any clarification you can give me on this point would be appreciated.

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 19:33:07
Script start
Timing: Jan 18 2025 19:33:07
Module start 'layout'
Timing: Jan 18 2025 19:33:07
Module start 'content'
Timing: Jan 18 2025 19:33:08
Module end 'content'
Timing: Jan 18 2025 19:33:08
Script end

Main resources:

Total runtime0.8223 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 589.1484152.6406
Module start 'layout' 0.00690.0035 741.789139.4766
Module start 'content' 0.01040.8104 781.2656536.3203
Module end 'content' 0.82080.0015 1,317.585912.4531
Script end 0.8223  1,330.0391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.4269160.0002
Check MTime0.00140.1703160.0001
Mysql Total
Database connection0.00080.098810.0008
Mysqli_queries0.768793.4781570.0135
Looping result0.00050.0639550.0000
Template Total0.786795.720.3933
Template load0.00230.276720.0011
Template processing0.784495.388520.3922
Template load and register function0.00010.015810.0001
states
state_id_array0.00170.203610.0017
state_identifier_array0.00150.186020.0008
Override
Cache load0.00190.2322380.0001
Sytem overhead
Fetch class attribute can translate value0.00070.087120.0004
Fetch class attribute name0.00220.264940.0005
XML
Image XML parsing0.00060.076920.0003
class_abstraction
Instantiating content class attribute0.00000.001640.0000
General
dbfile0.00080.1004170.0000
String conversion0.00000.001340.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 17
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs