Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
<txp:modified /> and <txp:posted />
Is there a way to use these tags together so that one states the date the article was posted and the other states the day it was modified – at the moment posted also posts the modified date.
Also can you display the author who modified the article?
Offline
Re: <txp:modified /> and <txp:posted />
Hi
Is this what you’re looking for :
<p class="published"> by <txp:author /> on <txp:posted /> <txp:php>
$changed = modified(array(
'format'=>'%m %d %Y - %H:%I'));
echo $changed ? '| Modified on '.$changed.' by '.safe_field("RealName", "txp_users", "RealName='".author(array())."'") : '';
</txp:php></p>
Add this code above withing your article form (perhaps the “default” one). If your article has been modified it will render that :
Published by Tye on 03 26 2009 – 10:38 | Modified on 03 29 2009 – 09:34 by President Obhama
… and if your article is’nt changed it will be display :
Published by Tye on 03 26 2009 – 10:38
Last edited by Pat64 (2009-03-29 07:54:58)
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: <txp:modified /> and <txp:posted />
Pat64 – Perfect… I think I’m going to have to learn more of this php stuff – merci beaucoup :)
Offline
Re: <txp:modified /> and <txp:posted />
tye wrote:
Pat64 – Perfect… (…) merci beaucoup :)
De rien. A ton service ;)
Bonne journée,
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
#5 2009-03-29 15:36:44
- rsilletti
- Moderator
- From: Spokane WA
- Registered: 2004-04-28
- Posts: 707
Re: <txp:modified /> and <txp:posted />
The code above is returning the original author as the last modified user. I’m getting this to work as described, if I understand correctly what you are asking for.
<p class=“published”> by <txp:author /> on <txp:posted /> <txp:php> $changed = modified(array( ‘format’=>’%m %d %Y – %H:%I’)); echo $changed ? ‘| Modified on ‘.$changed.’ by ‘.safe_field(“LastModId”, “textpattern”, “ID=’”.$thisarticle[‘thisid’].”’”) : ‘’; </txp:php></p>
Offline
Re: <txp:modified /> and <txp:posted />
Oops. You’re right Rick!
Sorry. Please refer to this new code : mine is wrong.
That’s why this comunity is incredible : we always find someone better than us.
Best regards Rick,
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: <txp:modified /> and <txp:posted />
Oops and re-Oops.
Tye and Rick the – correct – code is :
<p class="published"> By <txp:author /> on <txp:posted /> <txp:php> $changed = modified(array( 'format'=>'%m %d %Y – %H:%I')); echo $changed == posted(array('format'=>'%m %d %Y - %H:%I')) ? '' : '| Modified on '.$changed.' by '.safe_field("RealName", "txp_users", "name='".safe_field("LastModID", "textpattern", "ID='".$thisarticle['thisid']."'")."'");</txp:php>
Tested and re-tested successfully on TXP v 4.0.9
But a join query will be better…
Best regards,
Last edited by Pat64 (2009-03-29 18:02:46)
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
#8 2009-03-29 18:18:30
- rsilletti
- Moderator
- From: Spokane WA
- Registered: 2004-04-28
- Posts: 707
Re: <txp:modified /> and <txp:posted />
have you noticed anything along these lines by chance?, modified times
Offline
Re: <txp:modified /> and <txp:posted />
Yes Rick I noticed this difference between published and modified dates for a first created article (almost 20 seconds).
That’s why I need to use the format attribute to compare the two dates. Strange behavior…
Last edited by Pat64 (2009-03-29 21:57:52)
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline
Re: <txp:modified /> and <txp:posted />
Thanks both of you… I didn’t even notice that – but then I was only testing with my user name – doh! :)
Offline
Re: <txp:modified /> and <txp:posted />
I’ve been using the txp:tags-only version of this, posted by Els. Is this basically the same?
Offline
Pages: 1