Computing Consultants Archive: CityDesk Code Snippets

An unorganized 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.

None if the scripts have been updated to take advantage of the new features in SP1, yet...


This is the code I'm using to generate the list of the 10 most recent additions to the site while excluding the Index pages. The same script can be used on the Index.html page and in the site template.

<p><strong>Recent Additions</strong></p>
		{$foreach 10 x in (and(all)(not(keyword_contains "Index")))SortDescendBy .fileddate$}
		<p>{$x.fileddate$} {$x.headline$}   
		<A href="{$x.link$}">Read on</A>...</p>
		{$next$}

01/16/02 - As of today, I've put this into its own folder on its own page. There's a link to it on the menu rather than displaying it on every page.


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$}</A></p>
		{$ next $}

I use the "extra" 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$}">

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!

<div align="center"><center>
		<table border="0" width="100%">
		<tr>
		<td width="10%"><a href="index.html">H O M E</a></td>
		<td width="10%"><a href="../articles/index.html">Articles</a></td>
		<td width="10%"><a href="index.html">CityDesk</a></td>
		<td width="10%"><a href="../contents/sitemap.html">SiteMap</a></td>
		<td width="10%"><a href="../ponder/index.html">Things to Ponder</a></td>
		<td width="10%"><a href="../management/index.html">Content Management</a></td>
		<td width="10%"><a href="../new/WhatsNew2002.html">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 below.


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.

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

<p><a href="#top"><i>Back to Top</i></a></p>
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.

Here's my version of the script:

{$foreach x in (and(folder "Conditions")(not(keyword_contains "Index")))$} <a href="#{$x.extra1$}">{$x.headline$}</a><br> {$next$} <p> </p>
		{$foreach x in (and(folder "Conditions")(not(keyword_contains "Index")))$}
		<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.


Very basic script that I use to generate a sitemap. All this script does is make a list of links to all the articles in every folder in alphabetic order. It lives in its' own folder called Contents in an article called Contents.

{$ foreach x in (all) SortAscendBy .filename$}
		<P><A href="{$x.link$}">{$x.headline$}</A></P>
		{$ next $}

This is a Menu generating script that I'm using on the Index.html page & template. I made it a variable so I could easily tweak it in one place and have the changes applied to every instance.

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

It looks thru all the folders & makes a link to the "Index" pages sorted alphabetically by Headline. See above for the Index page script I'm using.