How to automatically display the first item of a folder?

|
|
Next topic
 »
Author Message

Aymeric Palsky

Thursday 25 August 2011 7:28:53 am

Hi,

As it is written in the title, I would like to know how to automatically display the first item of a folder?

If someone have an idea this will help me, thanks.

kracker (the)

Thursday 30 November 2023 3:24:38 am

Hello,

What you want is possible via a simple template fetch call made within your own custom template.

See the fetch 'limit' parameter, you can set it to 1 and only fetch the first item of your folder node.

See the docs first!

Here is an untested example:

{def $first_item=fetch( 'content', 'list', hash( 'parent_node_id', $indexpage,
                                   'limit', 1,
                                   'sort_by', array( 'published', false() ) ) )
<h1>{$first_item.name|wash}</h1>

Cheers,
//kracker

Theme: Lil Xan - (Don't) Watch Me Fall ...

Source: https://www.youtube.com/watch?v=l7lYWlzuHB8

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

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 17 2025 21:51:21
Script start
Timing: Jan 17 2025 21:51:21
Module start 'layout'
Timing: Jan 17 2025 21:51:21
Module start 'content'
Timing: Jan 17 2025 21:51:21
Module end 'content'
Timing: Jan 17 2025 21:51:21
Script end

Main resources:

Total runtime0.0180 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.0059 588.1406152.6406
Module start 'layout' 0.00590.0037 740.781339.4844
Module start 'content' 0.00950.0059 780.265689.6016
Module end 'content' 0.01550.0025 869.867230.2891
Script end 0.0180  900.1563 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002714.9566140.0002
Check MTime0.00126.9330140.0001
Mysql Total
Database connection0.00115.890010.0011
Mysqli_queries0.002614.362330.0009
Looping result0.00000.156210.0000
Template Total0.002111.510.0021
Template load0.00126.505510.0012
Template processing0.00094.974110.0009
Override
Cache load0.00084.307010.0008
General
dbfile0.00031.410980.0000
String conversion0.00000.049040.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