Fog Creek Software
Fog Creek Software

CityDesk 2.0-Documentation
Lesson 6 - Changing a Variable

Variables, which are elements of CityScript, can be used in articles or in templates to represent chunks of text you need to use more than once throughout your site. When CityDesk publishes a site it replaces all variables with the text each represents.

Suppose you have a mentally unstable boss who asked you to create a web site praising the Boston Red Sox. Since you know he is mentally unstable, instead of writing

The Boston Red Sox rule the Earth

you define a variable FlavorDuJour which is defined as Boston Red Sox. Now you can write things like:

The {$.FlavorDuJour$} rule the Earth

and

All hail the {$.FlavorDuJour$}!

As you can see, to use the variable name, we surround it with {$. (note the dot) and $} (no dot).

Now, next week, when psycho-boss wants you to change the site to praise, say, the Mighty Ducks instead, you just change the variable FlavorDuJour in one place and CityDesk takes care of the rest.

In the default set-up, the Simple template has a variable SiteName used for the title at the top of each page. To change the text inserted, just change the value of the variable.

*  In the main window, select View » Variables or click on the Variables tool on the toolbar.

Variables
Variables

You'll see a list of each variable’s name and the text it represents.

*  Double click on the variable called SiteName and give it another value. Give your site a name that reflects your individuality and creativity, like "Welcome To Jim's Home on the Web" (assuming that your name is Jim, of course).

Each time CityDesk sees something that looks like

{$ .SiteName $}

it will replace it with the text you just typed in.

*  Preview your site and notice how the title has changed on every page.

*  Next: Lesson 7 - Publish to an FTP Server

CityDesk Documentation -  Home


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