Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-12-31 13:08:28

aeris
Member
Registered: 2009-03-01
Posts: 12

show "last updated" date

Can I display the date of the first article somewhere outside of it? Eg. in the sidebar: “this site was last updated x days ago”.

mrz_lastsite_mod is gone, tcm_lastupdate doesn’t support PHP time format and shows a date over one year ago when the latest article was posted a couple of days ago. Experimenting with txp:article and article_custom with pgonly=“1” just produced some odd results :)

Offline

#2 2010-12-31 13:12:49

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: show "last updated" date

I’m using this:

<txp:php>
global $prefs;
$format = '%d-%m-%Y'; // CHANGE THIS TO FIT YOUR NEEDS
echo safe_strftime($format, safe_strtotime($prefs['lastmod']));
</txp:php>

If it’s just the most recent article’s date you want to display:

<txp:article_custom limit="1">
<txp:posted />
</txp:article_custom>

Last edited by els (2010-12-31 13:14:13)

Offline

#3 2010-12-31 13:28:41

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: show "last updated" date

I’m still using ob1_modified. Long an orphan, but still available and still works. With the plugin you could adapt Els’s code:

<txp:article_custom limit="1">
<txp:ob1_modified />
</txp:article_custom>

Code is topiary

Offline

#4 2010-12-31 13:37:30

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: show "last updated" date

jsoo wrote:

I’m still using ob1_modified. Long an orphan, but still available and still works. With the plugin you could adapt Els’s code:

TXP v4.0.7 introduced <txp:modified />.

Offline

#5 2010-12-31 14:39:23

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: show "last updated" date

OK, so I’m a little behind the times.

<txp:article_custom limit="1">
<txp:modified />
</txp:article_custom>

Edit: Now I remember why I am still using ob1_modified on one site: it has an option to only output the modified date if it differs from the posted date.

Last edited by jsoo (2010-12-31 15:55:36)


Code is topiary

Offline

#6 2010-12-31 18:10:36

aeris
Member
Registered: 2009-03-01
Posts: 12

Re: show "last updated" date

Els wrote:

If it’s just the most recent article’s date you want to display:

<txp:article_custom limit="1">
<txp:posted />
</txp:article_custom>

Thank you! That did the job. Can’t believe it was that simple…

Last edited by aeris (2010-12-31 18:12:38)

Offline

Board footer

Powered by FluxBB