Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Unique Field for Each Article

Okay, I'm trying to implement commenting on my CityDesk site, and have found a few services that do remote commenting.

However, to do this, I need to find something that is unique to each article, and then insert that into some Javascript the comment service uses. So, my question is this: Is there a unique field, that only appears on one article, and one article alone, and if there is, what would I use to include it?

Brian M Bommarito
Tuesday, April 06, 2004

Depending on how your site is set up you might be able to use      {$.filename$}. if your file names are not unique you'd probably need to use one of the other fields and place something unique in each.  Using {$.filename$} is probably a lot easier.

Ken McKinney
Tuesday, April 06, 2004

It's too bad you can't get at the Magic Name for the article...that would be perfect.

Brian M Bommarito
Tuesday, April 06, 2004

Scratch that.

I could...just copy and paste the magic name into the extra 1 field, and pull that...that could work, and wouldn't be a huge amount of work.

Brian M Bommarito
Tuesday, April 06, 2004

Why not just use {$.abslink$}?

Emperor Norton
Tuesday, April 06, 2004

Does that print out the unique URL for the article?

Brian M Bommarito
Tuesday, April 06, 2004

Yeah, {$.abslink$} is the absolute link for the current article.  CityDesk makes them unique, so that if you have two articles in the same folder named "foo", the .abslink for the first will be "/articles/foo" (or whatever) and the second will have an .abslink of "articles/foo-2".

It's unique to each article, and it's automatic, so you don't have to remember to cut and paste.

Emperor Norton
Tuesday, April 06, 2004

You can also create a quasi-unique ID use the combination of {$.filedDate$} and }{$.filedTime$}. This is the formula that John Conners uses in his CityDesk PHP comment system. It works simply because it's physically impossible to create two Citydesk articles in the space of a second.

I create a variable as follows ...

{$setDateTimeFormat "English" "yyyyMMdd" "HHmmss"$}{$.filedDate$}{$.filedTime$}

... and then call it whenever it's needed to crate a unique article ID.

It has only one gotcha that I know of: if you copy an item multiple times from another CityDesk file, using Copyboy, they will all have the same ID. This won't bother most people.

(I agree, though, that the program could usefully expose the unique ID. It would be nice to have this available for {$ include "articleUniqueID" $} as well, instead of having to use the article's name and path, which might change.)

David Walker
Friday, April 09, 2004

*  Recent Topics

*  Fog Creek Home