Textpattern features a txp:modified /> tag which can be used to output the last time one modified a given article.
Basic tag usage
Last modification: <txp:modified />
Which would result in something like this: Last modification: 29 September 2009
. The actual output depends on your date settings in the Preferences tab. You can place this within an article tag like so:
<txp:article limit="1">
<txp:body />
Last modification: <txp:modified />
</txp:article>
This would be suitable if you wish to display the last time an article has been modified.
Usage for an article in a given section
If you would like to display the last modified date for an article in a specific section, try this:
Last update: <txp:article_custom section='<txp:section />' limit="1" sort="LastMod desc">
<txp:modified />
</txp:article_custom>
This will output the last modified date for the latest article in the current section.
Custom date formatting
The <txp:modified />
tag accepts a format
argument which allows you to change the date formatting. Here is an example:
<txp:article_custom section='<txp:section />' limit="1" sort="LastMod desc">
Last updated: <txp:modified format="%Y-%m-%d"/>
</txp:article_custom>
Which would display something like: Last updated: 2009-01-31
Section check
The above code works if you know that you have some output for the section. If you need to change the output based on a particular section you can try this:
<txp:article_custom section='<txp:if_section name="">We are on the homepage<txp:else /><txp:section /></txp:if_section>' limit="1" sort="LastMod desc">
Last updated: <txp:modified format="%Y-%m-%d"/>
</txp:article_custom>
The code will check if we are on the default
page. If yes, display “We are on the homepage” followed by the modified date. If not, display the section name followed by the modified date.
Adjust according to your needs…