Fog Creek Software
Fog Creek Software

CityDesk 2.0-Documentation
Introduction to Templates

A template is a file, usually HTML, that contains CityScript surrounded by {$ and $}. CityDesk replaces the scripts in the template with data from each article to generate a final HTML page which is uploaded to your web server.

Here's a simple example. Suppose you have an article with the headline:

Kids Make Nutritious Snacks

and the body:

Reliable sources from local area Jefferson Middle School say that pupils in Mrs. Johnston's Seventh Grade Home Economics class made a snack consisting of muffins, mayonnaise, and a creamy cheese-like product.

This article is set up to use the NewsStory template, which you have defined as follows:

<html>
<head>
   <title>{$.headline$}</title>
</head>
<body>
  <h1>{$.headline$}</h1>
  {$.body$}
</body>

When this article is published, CityDesk replaces the text {$.headline$} (both places that it appears) with the headline of the story, and the text {$.body$} with the body of the story, producing a complete web page:

<html>
<head>
   <title>Kids Make Nutritious Snacks</title>
</head>
<body>
  <h1>Kids Make Nutritious Snacks</h1>
  Reliable sources from local area Jefferson Middle School say that pupils in Mrs. Johnston's Seventh Grade Home Economics class made a snack consisting of muffins, mayonnaise, and a creamy cheese-like product.
</body>

That's really all there is to it!

You can create as many templates as you want, one for each layout you want for your stories. Many web sites will only have one template, but if you find that boring or if you have several different types of stories, you can create more templates. When you create a story, you can select which template it uses on the Properties tab. You can change your choice at any time. You can even change the template as much as you want, and all the stories that use that template will reflect the changes the next time you publish your site.

CityDesk Documentation -  Home


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