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.
|