Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Can't figure this out



This is the latest code I've used.
{$if ({$.modifiedDate$} after {$.fileddate$}) $}:  Updated: {$x.modifiedDate$} {$endif$}

I am trying to simply display the modified date in the index if it is later than the fileddate. I have tried all sorts of different pieces of code. The error I receive is that the IF statement is expecting blank or nonblank.

Anyone know how I can do this?

I read a recent post dicussing modified date and todays date etc.

Thanks,

John

john Cesta
Friday, June 18, 2004

{$if  only excepts blank and nonblank.  Modifieddate  should be the same as filedDate if the article hasn't changed but I don't know of a way to conditionaly display one or the other.

Ken McKinney
Friday, June 18, 2004



I saw an archived post of a javascript code that would do this but I couldn't get it working 100%. It worked but it set all the dates on all the articles in the index to the same filed and modified.

I would like to be able to compare the filed date and modified date yes.

John

john Cesta
Friday, June 18, 2004

John,

Is this the posting you refer to?

http://discuss.fogcreek.com/CityDesk/default.asp?cmd=show&ixPost=11056&ixReplies=0

What is your code and what does it produce?

David.

David Watts
Friday, June 18, 2004


I have popped the code into my index page while the articles are being selected. What happens is all the dates are the same for every article.


write("<p>First published {$ .filedDate $} {$ .filedTime $}. Updated {$ .modifiedDate $} {$ .modifiedTime $}</p>")

article one: First published on 4/03/2002 updated on 6/18/2004

article two: First published on 4/03/2002 updated on 6/18/2004

article three: First published on 4/03/2002 updated on 6/18/2004

john Cesta
Friday, June 18, 2004

John,

The time and date are that of the current article. So if you're putting the code in your index article, its the date and time of the index file that's being printed. Or am I not understanding you?

David.

David Watts
Friday, June 18, 2004

John, This isn't what you want but I do it like this on this page:

http://ahoy.tk-jk.net:

For this site both the start date and revision date are helpful. I wish I'd have revision date when we started the site. I used to change the fileddate whenever I revised an article, so for much of the site we've lost track of the original publish date.

tk
Friday, June 18, 2004

but Dave, shouldn't the dates change within the index article in the loop? They change without using javascript.

Shouldn't each {$ .filedDate $} {$ .filedTime $}. {$ .modifiedDate $} {$ .modifiedTime $} be different with each itteration?

John

john Cesta
Saturday, June 19, 2004


Well, yea tk that is kinda what I want. I want to sahow when I updated an article.

john Cesta
Saturday, June 19, 2004



Sorry tk I forget, but I only want to show it on the articles that I did update not on all articles.

So if an article was updated I want it to show both created date and update date.

John

john Cesta
Saturday, June 19, 2004

John :re Publish & Modified Dates

I use the following script in my Templates. Perhaps this can help.

<script type="text/javascript">
//<![CDATA[
{$setDateTimeFormat "English" "MMMM dd, yyyy" "hh:mm:ss"$} // the format that the Date method requires
filedDate=new Date("{$ .filedDate $}")
modifiedDate=new Date("{$ .modifiedDate $}")
{$setDateTimeFormat "English" "ddd M/dd/yy" "hh:mm tt"$} // the format to print
with (document) {
  if (Date.parse(filedDate) == Date.parse(modifiedDate))
      write("Published {$ .filedDate $} {$ .filedTime $}")
  else
      write("First published {$ .filedDate $} {$ .filedTime $}.<br /> Updated {$ .modifiedDate $} {$ .modifiedTime $}")
}
//-->//]]>
</SCRIPT>

David Mozer
Saturday, June 19, 2004

John :Caveat

Please consider that if you happen to use *variables* that may populate some or all of your articles [I use a lot of variables] and you happen to change some/any of the data contained in those variables CityDesk will not see that currently as a modification -- so the modified date will have not changed when publised.

Apparently the only time that modified date works is if one actually makes changes [via edit] to the article itself -- and variables for some reason [IMO a bug] are not treated in the manner [being sensed for changes] that they should be.

David Mozer
Saturday, June 19, 2004



David,

No, the modified date is changed as I have changed a lot of the text in the article. I can see the date has changed.

Thanks

john Cesta
Saturday, June 19, 2004

John :re I have changed a lot of the text in the article.

I do not understand your message in the context of what I had posted.

Yes, if you edit an article the modified date will change. That also means that if you happen to *insert* a variable during an edit session the modified date will change.

But IF the only change to an article is made via an already *existing variable [whose content is changed]* populating that article the modified date will not change  --- via the script above.

David Mozer
Saturday, June 19, 2004



I would think that your javascript or any CS run within an index page loop would use the specfic variables (whatever they may contain) tied to each article with the loop.

I know that CS operates this way. Loop, read the variable associated with the article being processed and use the information within it.

I just can't figure out how to write a script that

Always displays the fileddate
Display the fileddate AND the modifieddate if the two dates are different.

John

john Cesta
Saturday, June 19, 2004

John, can you post the full loop code that is in your index file?

David.

David Watts
Saturday, June 19, 2004

Hang on a sec. Are you saying that you have the javascript code in your index file, not in each article? So you're creating some sort of list of articles, each with the created & modified dates?

If so, then make sure the date variables have the "x.":

write("<p>First published {$ x.filedDate $} {$ x.filedTime $}. Updated {$ x.modifiedDate $} {$ x.modifiedTime $}</p>")

Otherwise, it always uses the dates of the index file.

I think!
David.

David Watts
Saturday, June 19, 2004

David, you are correct. the "x." is the key to pulling dates from the article.

tk
Saturday, June 19, 2004



That may be the problem. I'll look at it.

John

john Cesta
Saturday, June 19, 2004



Thanks David that was the problem. The x wasn't there.

And the javascript code works great!

John

John Cesta
Saturday, June 19, 2004

Excellent. Glad it got sorted out.

David Watts
Saturday, June 19, 2004

*  Recent Topics

*  Fog Creek Home