Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-11-01 22:53:54
- fhd
- Member
- Registered: 2009-11-01
- Posts: 13
How to add a "Page last updated at..." info?
Hi,
I’m creating a rather static page, with only one or two pages actually containing articles in that sense. The others do only have a single fixed article, as described in the relevant FAQ entry.
Now at the bottom of each page, I’d like to display the date on which this particular page has been changed the last time.
Since a page corresponds to a section in my setup, I think I’ll have to get the modification date of the newest article in the current section, or something similar. However, I wasn’t able to figure it out on my own.
Can someone tell me how to do this?
Offline
Re: How to add a "Page last updated at..." info?
fhd wrote:
I’d like to display the date on which this particular page has been changed the last time.
Does this get you some of the way towards a solution:
Last update: <txp:article_custom section='<txp:section />' limit="1" sort="LastMod desc">
<txp:modified />
</txp:article_custom>
There might be a more efficient way to do it, as this is just off the top of my head. Hope it helps.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: How to add a "Page last updated at..." info?
I don’t know if this is more efficient, but this is how I approached it:
On your page where you want the “Last updated” message printed:
<txp:article_custom section="<txp:section />" form="updated" limit="1" />
And in the form named “updated”
Last updated: <txp:posted />
Offline
#4 2009-11-02 07:56:41
- fhd
- Member
- Registered: 2009-11-01
- Posts: 13
Re: How to add a "Page last updated at..." info?
Thank you both for the replies. I decided to use Bloke’s way since it wouldn’t require me to create another form.
It does work like a charm after adding status="sticky"
, which is what I do for my static pages.
Now I just need to have a custom date format, since I’m using it both for the “Last updated” and for a copyright notice (only the year).
But I believe I’ve seen that one on the FAQs, so it should be possible :)
Offline
Re: How to add a "Page last updated at..." info?
Hi fhd
You could probably use amordecosmos solution without a form by using the tag as a container one.
<txp:article_custom section="<txp:section />" limit="1">Last updated: <txp:posted /></txp:article_custom>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: How to add a "Page last updated at..." info?
colak & amordecosmos
Sure thing, both your solutions will work if fhd wants the posted date of the last article. I may have misinterpreted “I think I’ll have to get the modification date of the newest article” by using LastMod
and <txp:modified />
in my version. By all means drop them if dealing with posted dates.
fhd wrote:
Now I just need to have a custom date format
Both posted and modified tags take the format
argument which allows you to alter the tag’s displayed date format, e.g. format="%Y"
for just the year. If you are using this technique for copyright information, sed_copyright is an excellent plugin alternative as it handles all this automatically and does more besides.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#7 2009-11-02 12:47:53
- fhd
- Member
- Registered: 2009-11-01
- Posts: 13
Re: How to add a "Page last updated at..." info?
Bloke wrote:
Sure thing, both your solutions will work if fhd wants the posted date of the last article. I may have misinterpreted “I think I’ll have to get the modification date of the newest article” by using
LastMod
and<txp:modified />
in my version. By all means drop them if dealing with posted dates.
You did get it right, I was looking for the newest modification date on the respective page and it works as expected.
My final solution (which does exactly what I want) is:
<txp:sed_copyright owner="Me meself"/>
|
<txp:article_custom section='<txp:section />' limit="1" sort="LastMod desc">
Last updated: <txp:modified format="%Y-%m-%d"/>
</txp:article_custom>
Thank you all very much for the kind help!
Offline
#8 2009-11-02 13:11:20
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: How to add a "Page last updated at..." info?
is there a solution if i want to show for visitors when the whole site was last updated?
Offline
Re: How to add a "Page last updated at..." info?
Gallex wrote:
is there a solution if i want to show for visitors when the whole site was last updated?
Try taking out the section='<txp:section />'
attribute?
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#10 2009-11-02 14:21:52
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,308
Re: How to add a "Page last updated at..." info?
Bloke wrote:
Try taking out the
section='<txp:section />'
attribute?
logged out, waited, refreshed page – it’s displaying my current time. hmm…
my code Last updated: <txp:posted section='<txp:section />' />
Offline
Re: How to add a "Page last updated at..." info?
Gallex wrote:
my code
Last updated: <txp:posted section='<txp:section />' />
Why would you do that? <txp:posted /> doesn’t even have a section
attribute! :-s
You should try removing the section
attribute from the code that fhd posted because you want the article_custom tag to return the most recently modified article from all sections. That’s what you asked, right? Without the section
attribute, it returns all articles from all sections by default.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: How to add a "Page last updated at..." info?
This can be done without a form? <txp:jaw_drops />
Man, I missed a memo somewhere.
Offline