21278 Posts in 5728 Topics by 2599 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1091 Views |
-
Date in footer using $Now var

2 July 2010 at 12:01pm Last edited: 2 July 2010 12:17pm
I'm trying to update the copyright year in my sites footer dynamically by simply echoing the current year using the $Now var like this:
$Now.format(Y)
I'm using the $Now var in my my Footer.ss file which is an included file from the templates/includes folder, on multiple pages by means of a public function call from the Pages.php controller.
The $now var doesn't seem to work when the template is called as an include, but it works fine if I just use it in the template that's calling the include.
Any ideas are appreciated.
Chris.b
-
Re: Date in footer using $Now var

2 July 2010 at 12:24pm Last edited: 2 July 2010 12:35pm
$Now.Year works in includes. Don't forget to flush the cache with http://localhost/?flush=1
-
Re: Date in footer using $Now var

2 July 2010 at 1:08pm
Hmmm...
I just tried $Now.Year and it didn't work either. So I played a bit with the Footer.ss include and as it turns out
neither method works inside:<% if GetFooter %>
<% control GetFooter %>
-- Footer code here --
<% end_control %>
<% end_if %>Chris.b
-
Re: Date in footer using $Now var

2 July 2010 at 1:28pm
Specifically it's the <% control GetFooter %> part.
This works fine:
<% if GetFooter %>
-- Footer code here --
<% end_if %>Chris.b
-
Re: Date in footer using $Now var

2 July 2010 at 4:37pm
Its because $Now is part of the Page scope, not your GetFooter scope. If you're inside the GetFooter you'll need to use <% control Top %>$Now.Year<% end_control %>
| 1091 Views | ||
|
Page:
1
|
Go to Top |



