TK's CityDesk Help Reference

Bag of scripts

Bag of scripts

Saturday, January 19, 2008

Wednesday, September 15, 2004

These may be out of context, so you may have to fiddle with them based on your own folder and keyword names.


Using IFRAME, css, and .ASP to incorporate one site into another. In this case real estate listings, managed and publihsed in one CityDesk site, are incorporated into other sites with different styles.

http://www.lakemonticelloproperties.com/

http://www.patsystrongteam.com/listings.htm

http://www.patsystrongteam.com/listings.htm

http://www.fluvannacountyproperties.com/current_listings.htm

See how Deb does it here.


You should probably read this discussion but here is how the script actually turned out:

{$ foreach x in (and (folder "Reports")(after today-90)(not (keyword_contains "DisableListing"))) SortDescendBy .fileddate $}


A script to "print" the most recent change date:

This is what I do. It gives the "fileddate" of the article with the most recent "fileddate" I put in on the home page to reflect the most recent change to the site.

{$ foreach 1x in (all) SortDescendBy .fileddate $}{$x.fileddate$}{$next$}

I do this list the 5 most recent articles:

{$foreach 5x in (All) SortDescendBy .fileddate$}* {$ setDateTimeFormat "English" "dd MMMM yyyy" "hh:mm" $} {$x.fileddate$} - {$x.filename$}
{$next$}

  


How to do "where am I," breadcrumb navigation in CityDesk using javascript  the script and a downloadable example site.  This may be a holy grail for some thanks to Adriaan van den Brand


How to create an "if this field exists" script.

I want to create a sidebar, but only if there is a sidebar, so I set it up this way:

{$ foreach x in (filename "{$x.filename$}") $}
<table width="96%" border="0" cellspacing="2" cellpadding="2">
<tr bgcolor="#000000">
<td><font color="#ffffff">{$x.sidebar$}</font></td>
</tr>
</table>
{$next$}

It seems somewhat inelegant, is there a better way to do this?

Mark W


<table border=1>
<tr>
<td><STRONG>Headline</STRONG></td>
<td><STRONG>File Name</STRONG> </td>
<td><STRONG>Author</STRONG> </td>
<td><STRONG>Date Filed</STRONG> </td>
<td><STRONG>Keywords</STRONG></td>
<td><STRONG>Link</STRONG></td>
</tr>

{$ foreach x in (all) SortAscendBy .link$}
<tr>
<td><B>{$x.headline$}</B></td>
<td>{$x.filename$}</td>
<td>{$x.author$}</td>
<td>{$x.fileddate$}</td>
<td>{$x.keywords$}</td>
<td><A href="{$x.link$}">{$x.link$}</A></td>
</tr>
{$next$}

</table>

Mark W


Eric documents the CityDesk tricks on his site

Whole bunch of scripts and more by Eric


A way to generate a weblog-style archive page, where you have months listed which link to a page including the posts from that specific month

Q: Look at the bottom of this page:

http://joelonsoftware.com/navLinks/fog0000000247.html

It's a month by month archive of Joel's log.

Joel, how about showing us the script.

A:

It's not super-automatic. The list is generated:

{$foreach x in (folder "oldnews/pages")$}{$x.headline$}
{$next$}

The folder oldnews/pages contains a bunch of articles named "March 2000", "April 2000", etc.

Each of those looks basically contains this:

{$ foreach newsStory in (and (folder "news")
(and (after 2000/02/28) (before 2000/4/1)))
sortAscendBy .filedDate $}
{$newsStory.filedDate$}
{$newsStory.link$}"
{$next$}

Once a month I have to clone one of those articles and tweak the date ranges.

Joel Spolsky


Generate bookmarks:  In this example - questions at the top of the page and answers at the bottom.

1. at the top to generate the list of questions...

{$foreach x in (folder "Questions")$}
<a href="#{$x.extra1$}}">{$x.headline$}</a><br>
{$next$}

2. at the bottom to generate the list of answers...

{$foreach x in (folder "Questions")$}
<a name="{$x.extra1$}">{$x.headline$}</a><br>
<blockquote>{$x.body$}</blockquote>
{$next$}

Michael H. Pryor


Another method and the script to manage bookmarks

I made a couple additions to the script that others may find handy.

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.

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>&nbsp;</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.

Eric Chromick


Use a script to build a table that maps filename to the "fog url"

You can easily generate a (non-table) table mapping published name to file name. Make an HTML file containing this:

{$foreach x in (all)$}

{$x.link$} {$x.filename$}

{$next$}


List the URL, file name, and keywords for each article

{$foreach x in (all)$}
URL:  "{$x.link$}"
     Filename:  {$x.filename$}
         Keywords:  {$x.keywords$}


{$next$}

Terry Kearns


How to bullet links with a script

Here is the unbulleted script

{$ foreach 3 x in (and(folder "Minutes")(not(keyword_contains "archive"))) $}{$x.headline$}
{$next$}

You'll have to do this in HTML view:

<UL>
{$ foreach 3 x in (and(folder "Minutes")(not(keyword_contains "archive"))) $}<LI>{$x.headline$}</LI>
{$next$}
</UL>

The reason that you have to do it in HTML view is that in HTML it's not really allowed to put anything between the <UL> and the first <LI>, so the For Each will actually get moved somewhere else by the dang WYSIWYG editor.

Joel Spolsky


Generate text and pictures (from xtra fields) in a table for a real estate site

You should down load the sample site from here: http://www.fogcreek.com/~mhp/RealEstate.cty

<table border="0" width="100%" cellpadding="3" cellspacing="3">
    <tr>
   <td colspan="2" align="middle"><font size="2" face="Verdana"><b>Click on the property's address above the photo for more information</b></font></td>
 </tr>
    <tr>
   <td colspan="2" height="10">&nbsp;</td>
 </tr>
{$foreach x in (folder "Listings"){$
    <tr>
      <td width="75%">
     {$x.teaser{$<br>
  <font color="#ff0000"><b>Price:</b>${$x.extra1{$</font>
      </td>
      <td width="25%" align="middle"><b><A href="{$x.link{$"><B><FONT
      color=#0000ff>{$x.sidebar{$</FONT></B></A></b><br>
{$x.extra2{$
   </td>
    </tr>
    <tr>
      <td width="100%" align="middle" colspan="2"><hr></td>
    </tr>

{$next{$
  </table>

Michael Pryor


Month by month listing of weblogs:

Here is the page these scripts generate:

Look at the bottom of this page: http://joelonsoftware.com/navLinks/fog0000000247.html

It's not super-automatic. The list is generated:

{$foreach x in (folder "oldnews/pages")$}{$x.headline$}
{$next$}

The folder oldnews/pages contains a bunch of articles named "March 2000", "April 2000", etc.

Each of those looks basically contains this:

{$foreach newsStory in (and (folder "news")
(and (after 2000/02/28) (before 2000/4/1)))
sortAscendBy .filedDate $}
{$newsStory.filedDate$}
{$newsStory.link$}"
{$next$}

Once a month I have to clone one of those articles and tweak the date ranges.

Joel Spolsky


A script that manages a subfolder and articles that DON'T have a particular keyword

{{$ foreach x in (and (folder "IssueFolder") (not (keyword_contains "wholelist"))) $}
{$x.headline$}
{$x.body$}
{$next$}

Michael Pryor


Put keywords in Meta Tags.

Just put your keywords in the keyword field, for example

KeyWords: Fog Creek, CityDesk, CMS, Joel, Software

Then in the template for the articles, swith to HTML view and write

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

Michael H. Pryor


Back to Top