Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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
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
Offline
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 reachedcopyright 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 | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
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
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
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:
- Make it clear that the work is subject to copyright.
- Provide a means of identifying the copyright owner.
- Deter infringement or plagiarism.
So your TXP Tip code with the hyphen is fine.
In 4.8.4 I can do this:
Copyright © <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:
© <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)
Offline
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
Re: Get last time that site was modified, or latest server time
etc wrote #326539:
There is
blog_time_uid
pref that might fit here, but it is preset to2005
and never modified afaik.I’m off for a week, so can not investigate.
Have a well-deserved relaxing enjoyable covid-free break, Oleg. Thanks!
Offline
Re: Get last time that site was modified, or latest server time
In reality copyright should be on a per article basis, not site-wide. So if a site started in 2015, the first article could have a 2015-20 copyright but if an article was posted in 2019, that should be reflected in the copyright too. Check how I’m dealing with it in the NeMe site, at the bottom of the page, in the grey band.
Here’s the code at github.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline