Forums / General / How to automatically display the first item of a folder?

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/

eZ debug

Timing: Jan 21 2025 23:02:50
Script start
Timing: Jan 21 2025 23:02:50
Module start 'content'
Timing: Jan 21 2025 23:02:50
Module end 'content'
Timing: Jan 21 2025 23:02:50
Script end

Main resources:

Total runtime0.0241 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 591.2969180.8203
Module start 'content' 0.00680.0083 772.117294.1641
Module end 'content' 0.01500.0090 866.281370.6875
Script end 0.0240  936.9688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00229.2594120.0002
Check MTime0.00104.0820120.0001
Mysql Total
Database connection0.00073.035310.0007
Mysqli_queries0.004016.439240.0010
Looping result0.00000.079320.0000
Template Total0.008535.310.0085
Template load0.00093.895710.0009
Template processing0.007531.386510.0075
Override
Cache load0.00062.673410.0006
General
dbfile0.004217.2748100.0004
String conversion0.00000.024830.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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