computingconsultants.com
Content management and networking for small business and non-profits

CityDesk Howto's

A semi-organized collection of the scripts and other tidbits I'm using to make this site work. Most of these ideas have been developed with the gracious assistance of other CityDesk users in the CityDesk Forum.

As I add or change things I'll make the appropriate corrections here.

Note: some scripts have been rearranged to make reading and/or formatting easier.


An index page for each folder
Generate a menu
Generate a Sitemap
Generate Recent Additions & Updates
Generating a NavBar
Generating FAQ's
Keywords and Descriptions for each page
Using CSS (Cascading Style Sheets)
Using External Javascripts

 

An index page for each folder

This code generates the index page for each folder and excludes itself by using the Keyword "Index". I'll probably use the Teaser field to give a more complete description as time permits. This example creates the index for my "Things to Ponder" folder.

{$foreach x in(and(folder "Ponder")
(not(keyword_contains "Index")))$}
<p><A href="{$ x.link$}">
{$x.headline$}
{$next$}

The version below sorts the list by filename.

{$foreach x in (and (folder "Ponder")
(not(keyword_contains "Index"))) SortAscendBy .filename$}
<p><A href="{$ x.link$}">
{$x.headline$}
{$x.teaser$}
{$next$}

Version 2x uses the (thisFolder) variable and lets you exclude with (not(thisArticle)). Pretty slick!

{$foreach x in(and(thisFolder)(not(thisArticle)))$}
<p><A href="{$x.link$}">
{$x.headline$}</A><br>
{$x.teaser$}</p>
{$next$}

Back to Top

Generate a menu

This is the Menu generating script that I'm using in my main template. Originally, I made it a variable so I could easily tweak it in one place and have the changes applied to every instance, but I've since simplified some things and now it's part of the template.

{$foreach x in(and(all)(keyword_contains "menu"))
SortAscendBy .headline$}
<A href="{$x.link$}"> {$x.headline$}</A><br>
{$next$}

It looks thru all the folders & makes a link only to the pages that have the Keyword "menu" and sorts them alphabetically by Headline.

Back to Top

Generate a Sitemap

A very basic script that I use to generate a sitemap. All this does is make a list of links to all the articles in every folder, in alphabetic order, excluding files that have the keyword "index" or "exclude".

Since I use the keyword "index" as a table of contents for each folder I don't want that page to be listed, just the stuff that's in the folder. The keyword "exclude" is used primarily for the articles that make up various FAQ files, so I don't want them listed either. It lives in a folder called Contents in an article named Sitemap.

{$foreach x in (not(or(keywordContains "exclude")
(keywordContains "index")))
SortAscendBy .filename$}
<P><A href="{$ x.link$}">{$ x.headline$}</A></P>
{$next$}

Back to Top

Generate Recent Additions & Updates

Very similar to the Sitemap script, except it lists only the 10 most recently filed articles. Use the setDateTimeFormat as you prefer.

{$ setDateTimeFormat "*" "short" "hh:mm"$}
{$foreach 10 x in(and
(not(keywordContains "Index"))
(not(keywordContains "exclude")))
SortDescendBy .fileddate$}
<p>{$ x.fileddate$}&nbsp;{$ x.headline$}
<A href="{$ x.link$}">More</A>...</p>
{$ next$}

Back to Top

Generating a NavBar
I'm using a variable named {$.NavBar$} to generate the horizontal navbar on each page. As I add a section I copy the Magic Name and paste it in. The magical part of this is that CityDesk keeps track of how deep you are in the site and when published, the relative links all work. Amazing!

Note: I set the cell width at 10% (<td width="10%">) in the real script, but left it out here for page formatting purposes.

<div align="center"><center>
<table border="0" width="100%">
<tr>
<td><a href="PTMFOGXXXXXXX">H O M E</a></td>
<td><a href="PTMFOGXXXXXXX">Articles</a></td>
<td><a href="PTMFOGXXXXXXX">CityDesk</a></td>
<td><a href="PTMFOGXXXXXXX">SiteMap</a></td>
<td><a href="PTMFOGXXXXXXX">What's New?!</a></td>
</tr>
</table>
</center></div>

01/16/02 - I decided to go with a different look for the site, so I'm no longer using this one. See the Menu script.

Back to Top

Generating FAQ's

To be able to have a list of links at the top of an article that link to content on the same page, i.e. bookmarks, I'm using this script. It's used in a "FAQ-like" thing with 5 to 10 questions at the top that link to answers lower down. The text for the bookmark link is put into the extra1 field.

I made a couple additions to the script Michael Pryor wrote that others may find handy. Here's the original thread from the Forum - Bookmarking within an article

  1. In HTML view I put <a name="top"></a> as the first line so I could "Return to Top".
  2. I added <p>&nbsp;</p> between the scripts to give a little extra spacing between the list of questions and answers.
  3. I made the .Headline bold so it stands out.
  4. Added <p><a href="#top"><i>Back to Top</i></a></p> after the blockquote so you don't have to scroll back up. A personal issue on my part.
  5. Added the Keyword "faqpart" to exclude articles that are parts of FAQ's with a script that uses the "/*" operator.  

Here's my version of the script:

{$.teaser$}
<hr />
<a id="top" name="top"></a>
{$foreach x in (and(thisFolder)(not(thisArticle$}
<a href="#{$x.extra1$}">
{$x.headline$}</a><br />
{$next$}
<p>&nbsp;</p>
{$foreach x in (and(thisFolder)(not(thisArticle$}
<a name="{$x.extra1$}"><b>
{$x.headline$}</b></a><br />
<blockquote>{$x.body$}</blockquote>
<p><a href="#top"><i>Back to Top</i></a></p>
{$next$}

An observation on sticking scripts and text on the same page: I've found that if you create an article in Normal View and then insert the script in HTML view you're fine. However, once I switch back from HTML to Normal, my script gets mangled.

Back to Top

Keywords and Descriptions for each page

I use the "extra1" and "extra2 " fields on the Extras tab so I can list appropriate keywords and descriptions for each page or section. This code makes it work.

<META name="description" content="{$.extra1$}">
<META name="keywords" content="{$.extra2$}">

Back to Top

Using CSS (Cascading Style Sheets)

As an experiment, I've put my Cascading Style Sheet into an article and use the Magic Name in the site template to reference it. I chose the template (None) so there's no extra HTML to confuse the page display. I noticed that the filename winds up being style.html but it hasn't caused any noticeable problem with Internet Explorer.

Fog Creek recommends using an inline stylesheet as part of the template, and while I agree that this is the easiest way to go, it also forces your whole site to be uploaded if you make a change to the stylesheet.

I think I like my way better...

04/08/2002 - For some reason, it didn't occur to me until now that I could simply make a template with a .css extension and only the body tag thus solving the wacky name problem.

Back to Top

Using External Javascripts

You can call external Javascripts from a page by using "filename.js" just as you would any other time. I copy and paste the Magic Name of the file in place of "filename.js" in case I move the script around. Just to make it easier to keep track of things, I put all my Javascripts in a folder named Scripts.

The script itself is in an article that uses a template I defined called, surprisingly, Javascript. It has an extension of .js and only the body tag in the template.

Works every time.

Back to Top