View previous topic :: View next topic |
Author |
Message |
bimal Smarty Elite
Joined: 19 Apr 2007 Posts: 423
|
Posted: Wed Apr 21, 2010 4:36 am Post subject: Copyright Year on the footer |
|
|
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>© 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 |
|
Back to top |
|
DiscoInferno Smarty Rookie
Joined: 09 Aug 2011 Posts: 18 Location: Moscow, Russia.
|
Posted: Mon Aug 22, 2011 10:21 am Post subject: |
|
|
Yeahh! Thanks dude. I've been looking for this. |
|
Back to top |
|
Cummins Smarty n00b
Joined: 26 Aug 2011 Posts: 1
|
Posted: Fri Aug 26, 2011 10:57 am Post subject: |
|
|
Thanks |
|
Back to top |
|
SergiusWL Smarty n00b
Joined: 22 Feb 2014 Posts: 1
|
Posted: Sat Feb 22, 2014 8:05 pm Post subject: Thanks |
|
|
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 |
|
szombe Smarty n00b
Joined: 15 Jul 2014 Posts: 4
|
Posted: Tue Jul 15, 2014 4:54 am Post subject: |
|
|
Thanks! Was using Code: | {php}echo date('Y'){/php} | |
|
Back to top |
|
Vartiina Smarty n00b
Joined: 15 Feb 2016 Posts: 1 Location: Finland
|
Posted: Mon Feb 15, 2016 8:42 am Post subject: Don't know why |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Feb 15, 2016 9:34 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Feb 15, 2016 10:04 pm Post subject: |
|
|
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 |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Feb 15, 2016 10:58 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Mon Feb 15, 2016 11:07 pm Post subject: |
|
|
There is, but we're on the Smarty forum discussing Smarty tips and tricks. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Feb 16, 2016 9:45 pm Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Feb 16, 2016 9:55 pm Post subject: |
|
|
JavaScripts is NOT a HTML code. |
|
Back to top |
|
|