Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-10-23 14:42:30

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,414
Website

Get last time that site was modified, or latest server time

Hi,

Is there any way – with native tags (not PHP) – to find the last time that any articles on the site were modified/posted?

Or, if that is to much of a strain on resources, simply get the latest date from the server using native tags?

This would be handy to automate a copyright statement in a site footer, for example:

<p>Copyright {last-time-site-modified} MyCompany</p>

Usually I do it with this…

<p>Copyright <txp:php>echo date('Y');</txp:php> MyCompany</p>

..but since this is for a theme, I can’t guarantee that users will have PHP allowed in their templates.

Or, if there was a way to test whether that preference is set (i.e. a tag <txp:if_php>) then that would certainly help with theming.

Offline

#2 2020-10-23 15:40:54

etc
Developer
Registered: 2010-11-11
Posts: 3,989
Website

Re: Get last time that site was modified, or latest server time

philwareham wrote #326522:

Is there any way – with native tags (not PHP) – to find the last time that any articles on the site were modified/posted?

<!-- 4.8.4+ -->
<txp:article_custom fields="max(posted)">
    <txp:posted />
</txp:article_custom>

Or, if there was a way to test whether that preference is set (i.e. a tag <txp:if_php>) then that would certainly help with theming.

<txp:evaluate query='<txp:php />'>
    enabled
<txp:else />
    disabled
</txp:evaluate>

Offline

#3 2020-10-23 15:47:38

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,414
Website

Re: Get last time that site was modified, or latest server time

Wow, great – very handy to know! Thanks Oleg.

Is your 1st example OK on resources? Since this would potentially appear on the site footer of all pages I don’t want to use if it strains the database every time.

Offline

#4 2020-10-23 15:58:32

etc
Developer
Registered: 2010-11-11
Posts: 3,989
Website

Re: Get last time that site was modified, or latest server time

philwareham wrote #326524:

Is your 1st example OK on resources? Since this would potentially appear on the site footer of all pages I don’t want to use if it strains the database every time.

To test, but if MySQL server cache is well configured, this should not be a problem. Another (though roughly the same) way is

<txp:article_custom sort="Posted DESC" limit="1">
    <txp:posted />
</txp:article_custom>

Offline

#5 2020-10-23 16:15:50

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,391
Website

Re: Get last time that site was modified, or latest server time

Is it possible to automatically do: copyright 2020 if the theme is put into use now. Then when 1st January is reached copyright 2020, 2021 and so on for every new year that follows?


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

#6 2020-10-24 04:06:57

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,342
Website

Re: Get last time that site was modified, or latest server time

zero wrote #326526:

Is it possible to automatically do: copyright 2020 if the theme is put into use now. Then when 1st January is reached copyright 2020, 2021 and so on for every new year that follows?

Hi Peter,

Wouldn’t this become very long after a few years?

I think that from - today may be more economical. Here’s an old tip on how that can be done in order to avoid copyright 2020 - 2020.

On actually responding to your question which actually does make legal sense, one untested way may be:

copyright <txp:article_custom limiit="999" break=", " wraptag="">
<txp:if_different>
<txp:posted format="%Y" />
</txp:if_different>
</txp:article_custom>

The above should produce years for as long as there are new articles, jump a year if nothing is posted, and stop when the last article is posted. I believe that this is more legally correct than my method in the tips or by just arbitrarily incrementing the list of the years.

Copyright, normally states the year the work is created/released and lasts for some decades later, or-according to the Berne convention-for 75 years from the death of the author.


Yiannis
——————————
neme.org | hblack.net | State Machines | NeMe @ github
I do my best editing after I click on the submit button.

Offline

#7 2020-10-24 05:09:50

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,428
Website

Re: Get last time that site was modified, or latest server time

etc wrote #326523:

<!-- 4.8.4+ -->...
<txp:article_custom fields=“max(posted)”>
<txp:posted />
</txp:article_custom>

I’m loving it! Definitively (as all your suggestions, Oleg 😋)

With this small change to override the overall preference of the article date / time format:

<txp:article_custom fields="max(posted)">
<txp:posted format="%Y" />
</txp:article_custom>

Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#8 2020-10-24 08:41:42

gaekwad
Admin
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 3,221

Re: Get last time that site was modified, or latest server time

etc wrote #326523:

<!-- 4.8.4+ -->...

…which is coming in November, all being well. You can track the release plan here and keen testers are very welcome to offer advice and feedback.

Offline

#9 2020-10-24 09:46:19

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,391
Website

Re: Get last time that site was modified, or latest server time

colak wrote #326527:

Wouldn’t this become very long after a few years?

Yes it would Yiannis and I asked because I read on two (US) websites that there should be a year for each copyrighted work.

Your code:

© <txp:article_custom limit=“999” break=”, “ wraptag=”“>
<txp:if_different>
<txp:posted format=”%Y” />
</txp:if_different>
</txp:article_custom>

produced this for me © 2020 , , , , 2019 ,

Using this:

© <txp:article_custom sort=“Posted ASC” limit=“999” break=”“ wraptag=”“>
<txp:if_different>
<txp:posted format=”%Y” />
</txp:if_different>
</txp:article_custom>

produces this © 2019 2020

Is this legally acceptable? After searching again I found this clarification on a UK Copyright site: the aim of a copyright notice is to:

  1. Make it clear that the work is subject to copyright.
  2. Provide a means of identifying the copyright owner.
  3. Deter infringement or plagiarism.

So your TXP Tip code with the hyphen is fine.

In 4.8.4 I can do this:

Copyright &copy; <txp:article_custom fields=“min(posted)”>
<txp:posted format=”%Y” />
</txp:article_custom> – <txp:article_custom fields=“max(posted)”>
<txp:posted format=”%Y” />
</txp:article_custom> <txp:site_name />

to produce Copyright © 2018 - 2020 site.com but I wonder if there’s a way to do it and only use article_custom once. I suspect there is because field and fields both seem to work, but not as I expected:

&copy; <txp:article_custom field=“min(posted)” field=“max(posted)”>
<txp:posted format=”%Y” />
</txp:article_custom>

produces this: © 2020 2018

Last edited by zero (2020-10-24 09:47:45)


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

#10 2020-10-24 10:38:05

etc
Developer
Registered: 2010-11-11
Posts: 3,989
Website

Re: Get last time that site was modified, or latest server time

There is blog_time_uid pref that might fit here, but it is preset to 2005 and never modified afaik.

I’m off for a week, so can not investigate.

Offline

Board footer

Powered by FluxBB