Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Nesting Templates with CityDesk?

I am designing a site using CityDesk that has a custom navigational bar that I would like to define as a template, so that if it is updated, it is updated across the site. While I have sucessfully been able to embed the navigation bar as a CityDesk variable, the editing of variables and their values are particularly cumbersome (especially in comparison to the template/html editing tools).

Is there a way to embed multiple templated objects in a CityDesk "page"?

Wayne Earl
Friday, November 30, 2001

A variable is the right way to go for what you want to do here.

To make it easier to edit, you could create a dummy article or .html file (put it in a folder where it won't get in the way) so that you can edit it more easily, then cut and paste the HTML from there into the variable-editing-window.

Joel Spolsky
Friday, November 30, 2001

I had the same need (which is basic for a CMS) and it would be nice to be able to view more of the text in the variable area.
Nice software, I am giving it a try.

Philippe Back
Wednesday, December 05, 2001

You can actually resize the Variable window which lets you see more of the text at once. This helps a lot although I won't pretend that the Variable window is a nice editing environment :)

Joel Spolsky
Wednesday, December 05, 2001

When doing this with the variables, all is fine but you cannot nest variables or it only works to 2 levels deep.

If variables could refer to other variables and if variables could make it to the main 'tree' of CD, it would be a vast improvement.

Why having segregated the two instead of making a 'variables' entry in the tree ?

Ditto for the templates.


Philippe Back
Thursday, December 06, 2001

In principle you're right.

Historically, variables started out as a way to have little bits of text that change throughout the site. But we kept finding more and more powerful uses for them and some people have entire HTML blobs in variables.

In a future version we will make a template just be a variable that takes arguments, and we'll eliminate the two-levels-of-evaluation limit, and everything will be simpler and more powerful at the same time. But I hate vaporware, and should stop advertising features that we haven't written the code for :) Bad Joel.

Joel Spolsky
Thursday, December 06, 2001

I love hearing that. No nonsense. Very refreshing. I feel supported.

CityDesk is a very cool piece of software and I am showing it all around the place - I stayed glued to it in the office today - up to 20pm... forgetting to go home. The desktop app is the way to go: fast, neat, using a decent UI with real controls and not HTML-junk. Round tripping article/templates/help/preview/publish occurs very quickly. A real pleasure. As soon as I hit the 50 page limit, I buy a copy.

It moved me from a kludgy techy-oriented way of thinking to a spark of energy towards putting a bunch of semi-formatted texts in shape using CD I never expected to convert due to the burden of using HTML editors, MySQL and the like when I had no time left for that.

BTW I am currently on a (quite big) CMS project but CD doesn't cut it for this one... I hope that v5 will be able to compete there and it would be a pleasure to chat on this with you (hey, let's write some papers with CD about this !)

Philippe Back
Thursday, December 06, 2001

I just hit the two levels limit.

My right-hand navigation bar is assembled by iterating through the articles in a directory and building a table from their bodies. So, .RightNav is set to be equal to:

  {$ foreach x in (folder "nav/rightnav") $}
  <!-- {$ x.headline $} -->
  <tr><td align="left" valign="top">{$ x.body $}</td></tr>
  {$ next $}

Then I wanted one of those to contain a list of the top two archives, at which point everything breaks. I guess I'll have to pull RightNav out as a variable. :/

Garth Kidd
Sunday, December 09, 2001

Turns out I hit it twice; two levels is enough for foreach and a variable, but not a foreach and a variable containing a foreache and a variable. :/

Garth Kidd
Monday, December 10, 2001

Foreache? That'd be the risk of listening to a walkman on a golfcourse, I suppose.

My workaround for this one was to break things out more and duplicate some stuff. All of my index.html files and my templates now contain:


... with ArchiveNav foreaching my blog archives, and EndRightNav foreaching nav/right for anything else I might want to put in there.

The result: I've now completely integrated CityDesk with Blogger. I'll post some more in another topic and share the code.

Garth Kidd
Monday, December 10, 2001

... or maybe not. I left the cty file at home (no, really :), so can't pull out proper code and post a stripped version of the cty as an example.

FWIW, the admittedly rough integration with Blogger can be found at

Garth Kidd
Monday, December 10, 2001

*  Recent Topics

*  Fog Creek Home