Templates, Variables and Scripting
 
Sunday, October 06, 2002  

The flexibility and power of CityDesk using page templates, variables and scripting.

Page Templates

Every article must have a page template associated to it. You do this on the Propeties tab of the Article, at the bottom. The page template is the html structure of the web page that gets published.

I used the basic page structure as the start of my three templates.

Basic2Col: This is my default template. It's the template for this page. I don't use the right column, so I made its width=40 so that the margin of the text in the center is inside the edge of the masthead graphic.

Basic3Col: This one uses the right column for sidebar links, etc.

BasicHome: I made a separate template for the home page so I can goof around with it without affecting the rest of the site. I also have a different menu for the home page that doesn't have the Home link.

For the non-profit, I added on more:

BasicArticle: This one collapse both the left and the right columns. The only menu item on the left is a link back to the section index page.

Variables

I didn't quite understand how to approach variables until I cleared up a bit of symantics.

The CityDesk manual says to use variables for repeated text. This made more sense to me when I realized that there are two meanings for the word text. In publishing, text generally means the content, the written words. In programming, text generally refers to a type of data, such as ascii or binary.

I find variables much more useful when I think of text as a data type rather than content per se. Data types I've used are plain text, html tags, javascript, CityDesk scripting and CityDesk magic names. I'm sure other scripting languages would fit, too, but to the most part they require specific modules on the web server.

Scripting

CityDesk has its own simple scripting language. Now, I'm not a programmer, so I rely heavily on the examples provide in the Help pages. I have found that the examples are well thought out, and I get by just fine by copying and pasting them.

A significant discovery made from looking at one of Joel's site templates is that you can put CityDesk scripting in Articles on the Html tab. This means that you can present a table of contents on one page and not have to make a separate template for it.

Magic Names

There are two references to each CityDesk article, html page, or image stored on the desktop. There's the file name you give it, and there is the Magic Name generated by CityDesk. To get the Magic Name, right click on the article, page or image and select Copy Magic Name.

Use Magic Names instead of the file name, especially in variables and templates. When CityDesk publishes the site, it automatically translates the Magic Name into the proper html reference. For instance, use:

 <a href=PMTGFOG00000089>link</a>

instead of:

 <a href=../link.html>link</a>

Before I figured this out, I made two or three menus, each with different href statements, and then I had to keep them straight.

Best of all, if you use Magic Names you don't have to worry about losing track of links if you move an article from one folder to another or to a new folder. CityDesk will create the proper link structure the next time you publish.