Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

1 bug, 1 deficiency

bug: setDateTimeFormat ignored in Articles

Part of my site is a collection of poetry. I don't have full dates on all of them; sometimes I have month and year, sometimes I just know the year when I wrote the poem. I want to use a single template and override the date format in the article itself based on the sort of information I know I have.

It's not letting me do so.

deficiency: I can't use a property (well, at least a property) as a parameter to a {$foreach...$}. I want to do something like:

{$foreach article in (folder {$.extra1$}) SortDescendingBy .fileddate $}

I've gotten around it by now by putting the whole {$foreach$} inside of each article, but that seems to be a waste of code.

(Grr. I keep getting errors because I want to type ${ instead of {$.)


Austin Ziegler
Thursday, October 18, 2001

In which field are you trying to put the {$setDateTimeFormat$}?

I wonder if this is actually the documented behavior -- that quiet little note in the Help file that says: "It is a limitation of CityDesk that you can't use two different formats inside the same foreach block."

Perhaps it would just be easier just to use the Extra1 field for the date, formatted the way you like it for each article.

Joel Spolsky
Thursday, October 18, 2001

I've put the {$setDateTimeFormat ...$} in the article itself. The only previous {$setDateTimeFormat ...$} is outside of a {$foreach$} block.

This may be the documented behaviour, but it's definitely not what I'd consider the expected behaviour. I'm presuming that this would apply to things added during the processing of a {$.body$}, for example, right?

It might be possible to use the Extra1 field, but it'd be frustrating to do though, as it would also be necessary to have a separate template just for the poetry (I do want the "usual" behaviour of the default template for other articles, for example.)

If it isn't a bug, I'd consider it a behavioural deficiency (as with the other item). I'll echo someone else's call for a bit of if/else logic.

Overall, I'm finding this much better as a concept, and even if I end up doing further reprocessing because of the nature of what I want to do, it's something that I can forsee using and definitely recommending to others.


Austin Ziegler
Thursday, October 18, 2001

Thanks, I'm glad you like the concept.

Back to the setDateTimeFormat... can you email me a copy of your .CTY file (or even a small sample .CTY file which illustrates the template you're using and one or two of the articles)? I'm curious to see what's going on :)

Joel Spolsky
Thursday, October 18, 2001

OK, now I understand why your setDateTimeFormat isn't working:

In the simplest possible example, imagine that your template is:

And in the body you have
something {$setdatetimeformat...$} something

The first thing CityDesk does is fill in the template.
It replaces body with the body and filedDate with the date, giving you:

something {$setdatetimeformat...$} something
October 16th, 2001

Then it runs the parser one more time, looking for any scripts that were in the body. But by now, it's too late to affect the formatting of the date, because that has already been inserted.

I hope this explanation makes sense :)

A better design would be for us to scan the body for script and run that before inserting the body. That would be a big scary change so it will probably have to wait until the next version.

Joel Spolsky
Friday, October 19, 2001

Ah, I was expecting point-evaluation (probably not the right term, but more or less):

eval {$template$}

{$template$} contains:


This gets interpreted as:

eval {$.body$}
eval {$.fileddate$}

In some sort of pseudo-code.

It makes sense, it just means that I have to change a few things and use multiple templates. Question: if my article body contains {$.fileddate$}, will it work? (I won't be able to check this until tonight, as I have too much to do today.)


Austin Ziegler
Friday, October 19, 2001

*  Recent Topics

*  Fog Creek Home