Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Kinda Complex Layout Question

I'm hoping I can do this with CityDesk.

I'm trying to emulate a page I did awhile back using MovableType, and even in MovableType this took some playing. What I want to do is that I have multiple 'sections' in my site. And on the front page, I want to list all those 'sections' plus the last 3 articles in each of them, but I wanna show them in a special way.

The first, and most recent article in each section, I want to show the title + teaser + date posted. Then, on the next 2, I just want to show the title + date posted, no teaser.

I thought about doing multiple for loops, however, I don't know if you can tell CD to ignore first article (When sorted by date) and go on to the next one. Any help would be appreciated.

Brian M Bommarito
Friday, April 09, 2004

You could do it with javascript... although my syntax is not going to be perfect.

So use two for loops like this

{$ foreach 3 y in (folder "foo") $}
{$ y.title $} - {$y.fileddate$}
<span id="{$y.headline$}"></span>
{$ next $}

{$ foreach 1 x in (folder "foo") $}

<javascript>
document.getElementById("$ x.headline $}").innerHTML = "{$x.teaser$}";
</javascript>

{$ next $}


The first sets up an empty span for each article, and the second fills it in.

Michael Pryor
Fog Creek Software
Friday, April 09, 2004

Thanks Michael for the suggestion.

While reading through your idea, I came up with an idea myself, that I should have thought about in the first place. And, so I have decided to post it here, in case someone else wants to use it.

My idea was to use PHP to create an array of objects that each hold the headline, date, time, teaser of the three articles. From there, it's just a matter of starting with pulling out the data from say $posts[0], then drop into a loop to pull the remaining two.

The advantage that I see with using PHP, is that you don't have to worry if someone has turned off their Javascript in their browser, which I know a few do. The disadvantage is that it requires a bit more of the hosts processor power to create.

Brian Bommarito
Friday, April 09, 2004

*  Recent Topics

*  Fog Creek Home