Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Copyright Year on the footer

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Wed Apr 21, 2010 4:36 am    Post subject: Copyright Year on the footer Reply with quote

When you want to print out the copyright year on the footer of your page, the below solution will be amazingly useful. In the template file, put a piece of code like:

Code:
<p>&copy; 2006 - {'Y'|date}, <a href="http://www.sanjaal.com/">Sanjaal Corps</a>, All rights reserved.</p>


You should change it with your own texts. The {'Y'|date} will print the current year - that changes automatically, every year - without the need for extra coding Smile
Back to top
View user's profile Send private message Visit poster's website
DiscoInferno
Smarty Rookie


Joined: 09 Aug 2011
Posts: 18
Location: Moscow, Russia.

PostPosted: Mon Aug 22, 2011 10:21 am    Post subject: Reply with quote

Yeahh! Thanks dude. I've been looking for this.
Back to top
View user's profile Send private message Visit poster's website
Cummins
Smarty n00b


Joined: 26 Aug 2011
Posts: 1

PostPosted: Fri Aug 26, 2011 10:57 am    Post subject: Reply with quote

Thanks
Back to top
View user's profile Send private message
SergiusWL
Smarty n00b


Joined: 22 Feb 2014
Posts: 1

PostPosted: Sat Feb 22, 2014 8:05 pm    Post subject: Thanks Reply with quote

Realy thanks for the post ! Bingo ! I'm always forgot very simple things and in the searching of true result spending too much time!
None of documentation will give the answer so fast as search in google.
Back to top
View user's profile Send private message
szombe
Smarty n00b


Joined: 15 Jul 2014
Posts: 4

PostPosted: Tue Jul 15, 2014 4:54 am    Post subject: Reply with quote

Thanks! Was using
Code:
{php}echo date('Y'){/php}
Laughing
Back to top
View user's profile Send private message
Vartiina
Smarty n00b


Joined: 15 Feb 2016
Posts: 1
Location: Finland

PostPosted: Mon Feb 15, 2016 8:42 am    Post subject: Don't know why Reply with quote

But I have forgot to put that ' Y ' there, stupid me.... Anyways, this will help my friend's website a lot, thank you a lot!
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Feb 15, 2016 9:34 pm    Post subject: Reply with quote

FYI javascript works too, no server-side computation necessary, unless for some reason you want a non-localized year.

Code:
<script type="text/javascript">
  document.write(new Date().getFullYear());
</script>
Back to top
View user's profile Send private message Visit poster's website
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Feb 15, 2016 10:04 pm    Post subject: Reply with quote

I would rather have the page look the same regardless if a user have running JS interpreter.

P.S.
{"%Y"|strftime} and you will have correct localized year according to your running script's locale.
You do set correct locale for your scripts, right? Right?…
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Mon Feb 15, 2016 10:58 pm    Post subject: Reply with quote

AnrDaemon wrote:
I would rather have the page look the same regardless if a user have running JS interpreter.

P.S.
{"%Y"|strftime} and you will have correct localized year according to your running script's locale.
You do set correct locale for your scripts, right? Right?…


Sure, someone may also have a use of page templates being compatible using Smarty or not.
Back to top
View user's profile Send private message Visit poster's website
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Mon Feb 15, 2016 11:07 pm    Post subject: Reply with quote

There is, but we're on the Smarty forum discussing Smarty tips and tricks.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Tue Feb 16, 2016 9:45 pm    Post subject: Reply with quote

AnrDaemon wrote:
There is, but we're on the Smarty forum discussing Smarty tips and tricks.


Yes and there is nothing wrong with writing HTML code such that the headers/footers can work in PHP/Smarty or other places such as static parts of the website. Completely valid tip.
Back to top
View user's profile Send private message Visit poster's website
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Feb 16, 2016 9:55 pm    Post subject: Reply with quote

JavaScripts is NOT a HTML code.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP