Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-03-29 02:53:57

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

<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

#2 2009-03-29 07:39:06

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

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

#3 2009-03-29 09:16:10

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

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

#4 2009-03-29 12:59:20

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

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

#6 2009-03-29 17:11:51

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

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

#7 2009-03-29 17:46:40

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

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

#9 2009-03-29 21:52:17

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

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

#10 2009-03-30 04:41:33

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

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

#11 2009-03-30 20:32:11

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

Board footer

Powered by FluxBB