Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
latest modified article
I am trying to get the latest posted or modified (whichever is more recent) date from articles in all sections.
At the moment I have
<txp:article_custom section="section1,section_2,etc" sort="LastMod desc" limit="1" form="">
<txp:modified format="%a, %m %b %Y %X GMT" />.
</txp:article_custom>
but it does not seem to work.
> Edited title for clarity
Last edited by colak (2019-01-20 17:31:46)
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: latest modified article
What you’ve done looks correct to me. Jonathan wrote a textpattern tip on this that is similar to what you have, the only main difference being the GMT
you have in there. Maybe try reducing the sections first, and also see if you get any output first, e.g. txp_title, and then debug from there, adding them back in once you’ve found the problem.
One more thing: I don’t think the attribute form=""
is necessary either when using it as a container tag.
There’s also this method that outputs the last_modified date for the whole site, but that also includes updates you may have made on the admin side to forms etc. so isn’t strictly the last article update.
<txp:php>echo safe_strftime('%a, %e %b %Y %X', get_lastmod(), 1) . " GMT";</txp:php>
TXP Builders – finely-crafted code, design and txp
Offline
Re: latest modified article
the php, is not really handy as I do minor adjustments to the code very regularly.
The code I have posted above should work. Even if it means saving a live article for just another one time after publishing it, something I normally do as I always find a minor glitch which needs to be corrected. Going to Content>Articles and sorting by modified I get 15 Jan 2019 14:31:59
in a section which I include in the txp snippet. Interestingly what the code returns is 01 Jan 2019 14:31:59 GMT
which is totally wrong for two reasons.
- The most recently modified article is on the 15th
- The 1st Jan modified article was, according to the db, modified at
10:43:26
>Edited to clarify that the articles show no article which was modified on 01 Jan 2019 14:31:59 GMT
as parsed by the snippet.
Last edited by colak (2019-01-20 16:17:34)
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: latest modified article
colak wrote #316191:
the php, is not really handy as I do minor adjustments to the code very regularly.
Yep, thought as much.
Going to Content>Articles and sorting by modified I get
15 Jan 2019 14:31:59
in a section which I include in the txp snippet. Interestingly what the code returns is01 Jan 2019 14:31:59 GMT
Ah, well that is probably because %m
means a two-digit representation of the month. What you want there is %d
(01-31) or %e
(1-31). Had to put my glasses on too to spot that ;-)
TXP Builders – finely-crafted code, design and txp
Offline
Re: latest modified article
Yep!!! that was it. I was pulling my hair out as it was such a simple thing to do but I just could not see it. Thanks again Julian.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Pages: 1