Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Newbie Question

How do I include the latest article in a particular folder on the home page? I can't seem to find out how to do this seemingly simple task, but I've had a long day :-(

CRC
Friday, August 01, 2003

This is a styleless, tasteless kludge, but you might try creating a folder called "latest", putting a copy of the latest article from each folder in it, and then looping over it with cityscript. When you create a newer article, just copy it into the "latest" folder and delete the old one.
If there is a slicker way to do this I'd love to know as well.

Israel Orange
Friday, August 01, 2003

Do a foreach loop for just one item and sort on date.  That will give you the most recent article in the folder

Joel Goldstick
Friday, August 01, 2003

Here is a snippet from the help file under Scripting with Cityscript -- creating a loop:

{$ forEach n var in (condition) sort-order $}
.... loop body ....
{$ next $}

set the n to 1 and set the condition to folder in question.  I think the sort-order should be descending on publishedDate

If you don't put a sort order

Joel Goldstick
Friday, August 01, 2003

{$ foreach 1 x in (folder "theFolderInQuestion") sortDescendBy .filedDate $}
<a href="{$x.link$}">{$ x.headline $}</a>
{$ next $}

Joel Spolsky
Friday, August 01, 2003

I guess I wasn't clear in my question. I saw how to create a link to an article, but I want the article itself to appear on the home page.

My left navigation would have links to the ten (or so) latest articles, but main content area on index.html would contain the latest article itself.

I see this kind of thing all the time on blogs, so I thought it should be fairly simple to do.

CRC
Friday, August 01, 2003

in the loop, use x.body to print the body of the article on the page

Joel Goldstick
Friday, August 01, 2003

that is,

{$ foreach 1 x in (folder "theFolderInQuestion") sortDescendBy .filedDate $}
{$ x.body $}
{$ next $}

Joel Spolsky
Saturday, August 02, 2003

Thanks, everyone.

CRC
Saturday, August 02, 2003

*  Recent Topics

*  Fog Creek Home