Fog Creek Software
Fog Creek Software

CityDesk 2.0-Documentation
Lesson 5 - Changing the Front Page

Your site contains an article named index. This is there because most web servers look for a file named index.html to display when web visitors enter the site.

*  Double click on index from the main window to edit the front page.

This opens up the front page in a built-in word processor. Articles can contain CityScript just like templates.

What's going on in this file? Let's look at the CityScript one line at a time. Follow along:

{$forEach x in (folder "articles")$}
This is the beginning of a loop. CityDesk will repeat everything between the forEach statement and the next statement once for every article in the folder named articles.

{$x.headline$}
This pulls out the headline from the article. Notice that this appears in blue with an underline. You know what that means, right? Right! It's a link! Specifically, a link to the article itself. If you select the linked text and bring up the Link dialog (Ctrl+L or Insert  »  Link) you'll see that the link is going to {$x.link$}. CityDesk will replace {$x.link$} with the article's actual URL at publishing time.

{$setDateTimeFormat "English" "MM/dd/yy" "hh:mm"$}
This sets the format that CityDesk will use for printing dates. Why do we care? Well, because we're about to print a date:

{$x.filedDate$}
Ah yes, that prints the date that the article was filed.

{$x.teaser$}
This displays the teaser field from the article: a short block of text on the home page that makes people want to read the article.

{$next$}
And that's the end of our loop. If there are any more articles remaining that we haven't printed, CityDesk jumps back up to the forEach statement and runs through it all again, this time assigning x to a different article. When we've finished listing all the articles, CityDesk will stop looping.

*  Close the index window.

*  Next: Lesson 6 - Changing a Variable

CityDesk Documentation -  Home


 ©Copyright 2001-2003 Fog Creek Software, Inc. All Rights Reserved.