Page 1 of 1
nVelocity for current YEAR?
Posted: Fri May 29, 2009 12:21 pm
by NC Software
In my footer I'd like to have the Copyright YEAR value automatically set so I never have to touch it again. Can this be done using nVelocity?
Re: nVelocity for current YEAR?
Posted: Fri May 29, 2009 12:34 pm
by Logan Rhodehamel
This would be roundabout, but $User.LastActivityDate.Year would probably do it. The LastActivityDate is always set for the user with the date the request was initiated. So long as your server time is correct, that will show the current year.
Re: nVelocity for current YEAR?
Posted: Fri Jun 19, 2009 4:26 am
by mihkeltt
A bit more elegant solution would be to add
into the Page.Items dictionary which you have access from the template as
Code: Select all
$page.Items.get_Item("currentDate").Year
. Bear in mind that the date should be inserted into the items collection very early on in the page lifecycle. One point for this would be in global.asax in the
Code: Select all
Application_PreRequestHandlerExecute
event. The current page can be accessed there via
Code: Select all
HttpContext.Current.Handler as Page
.
Mihkel
Re: nVelocity for current YEAR?
Posted: Fri Jun 19, 2009 6:25 am
by kastnerd
I like this