Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

forEach 1 x+1

sorry for yet ANOTHER question
but i can't find an answer by looking back though the old topics

If on my front page i want to include the 2 newest articles
but the first one/ probably easier to show the code

<!-- first article-->
{$ forEach 1 x in (all) sortDescendBy .filedDate $}
<p>{$x.headline$}<br />
{$x.body$}<br />
{$x.author$}<br />
{$x.filedTime$}<br />
{$x.filedDate$}</p>
{$ next $}

<!--second article-->
{$ forEach 1 x+1 in (all) sortDescendBy .filedDate $}
<p>{$x.headline$}<br />
{$x.teaser$}<br />
<a href="{$x.link$}">Read More</a>
{$x.author$}<br />
{$x.filedTime$}<br />
{$x.filedDate$}</p>
{$ next $}

so what can i do to pic out the second article?

Dave Heath
Saturday, August 21, 2004

foreach 2x will grab two articles.

On this page:
http://ahoy.tk-jk.net
I do a 12x to show Mac's latest aticles and a 15x to show the "Latest updates."

tk
Saturday, August 21, 2004

P.S. There is also a 1x in the footer to generate the latest copyright year "Copyright © 1984/2004" (the 2004 part).

tk
Saturday, August 21, 2004

hey cheers for the suggestion
but its not quite what i was wanting (i am however using that method for my own, latest update sidebar too)

i want just the second article, or a way of formatting the second result of a loop differently to the first

I have a feeling there was a way of doing it, but it was a year ago that i last had a proper go at "learning" citydesk and i no longer have what i did

Dave Heath
Saturday, August 21, 2004

ah ha!  instead of {$ next $} you can use {$ odd $} and {$ even $}

this gives you the odd and even articles and so if you just do

foreach 1 x ...
....
{$ even $} you just get the second article

Dave Heath
Sunday, August 22, 2004

That is a very nice trick!

Joel Goldstick
Wednesday, August 25, 2004

*  Recent Topics

*  Fog Creek Home