Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-11-05 16:32:07

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

(Solved) Clearing the <txp:modified /> time stamp

Aside from manually editing the database table field, is there a way to remove or modify the references to ‘Last modified by:’ in an article?

I ask because I occasionally write articles with future timestamps which use posted and modified tags in the article form. These articles have a publish date in the future but a modified date in the past.

Here’s an example article — note the timestamps underneath the title. I can clear the modified timestamp with ‘Reset time to now’ but that will reset the time to now, defeating the point of publishing in the future.

Any ideas gratefully received.

Last edited by gaekwad (2012-11-14 11:58:50)

Offline

#2 2012-11-05 16:48:36

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: (Solved) Clearing the <txp:modified /> time stamp

Can’t help with code ATM but there will be a way to convert both modified and posted date entries to “universal” time strings like 20121105174722, compare them against each other and feed some conditional variable with the outcome, thus avoiding outputting the contradicting modified date (or whichever you prefer to hide) if the right condition is met.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2012-11-05 16:50:48

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Re: (Solved) Clearing the <txp:modified /> time stamp

Oh, great idea. Thanks for the tip – I’ll get onto that!

Thank you, Uli.

Offline

#4 2012-11-05 23:16:32

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: (Solved) Clearing the <txp:modified /> time stamp

Back with code:

<txp:aks_var name="date-comparison" value='<txp:modified format="%y%m%d%H%M" />' calc='> <txp:posted format="%y%m%d%H%M" />' />

<txp:if_variable name="date-comparison" value="1">
  <txp:modified />
</txp:if_variable>

This here calc='> is not a copy/paste remainder, it makes aks_var compare both values and outputs 1 if the condition is met. (An output of 0 is not possible as it seems. So something in any of the comparisons has to be switched. But there are enough components to work with.)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#5 2012-11-06 00:24:19

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Re: (Solved) Clearing the <txp:modified /> time stamp

Well, that just saved me a morning of research and code finagling — thank you again, Uli!

Offline

#6 2012-11-14 11:34:03

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Re: (Solved) Clearing the <txp:modified /> time stamp

Hi again, Uli.
I’ve found time to use your code and it works exactly as expected. For your information, I changed the format slightly to use epoch time and avoid any potential daylight saving time weirdness:

<txp:aks_var name="date-comparison" value='<txp:modified format="%s" />' calc='> <txp:posted format="%s" />' />

Thank you, again – I really appreciate your help.

Offline

#7 2012-11-14 11:42:40

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: (Solved) Clearing the <txp:modified /> time stamp

Amazing one-liner:

<txp:etc_query data='<txp:modified />' query='string(*[''<txp:modified format="%s" />'' > ''<txp:posted format="%s" />''])' />

Offline

#8 2012-11-14 11:47:24

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,356
GitHub

Re: (Solved) Clearing the <txp:modified /> time stamp

etc wrote:

<txp:etc_query data=’<txp:modified />’ query=‘string(*[‘’<txp:modified format=”%s” />’‘ > ‘’<txp:posted format=”%s” />’‘])’ />

Now you’re just bragging ;)

Offline

#9 2012-11-14 12:05:25

etc
Developer
Registered: 2010-11-11
Posts: 5,397
Website GitHub

Re: (Solved) Clearing the <txp:modified /> time stamp

Touched :)

Offline

#10 2012-11-14 12:15:58

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: (Solved) Clearing the <txp:modified /> time stamp

gaekwad wrote:

For your information, I changed the format slightly to use epoch time and avoid any potential daylight saving time weirdness

Ah, that teaches me to not use the German translation of the php.net manual again. I first thought my memory was playing tricks on me when I found I had to assemble the complete date string from time atoms, but %s is simply not included in German.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB