nVelocity for current YEAR?
- NC Software
- AbleCommerce Partner
- Posts: 4620
- Joined: Mon Sep 13, 2004 6:06 pm
- Contact:
nVelocity for current YEAR?
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?
Neal Culiner
NC Software, Inc.
NC Software, Inc.
- Logan Rhodehamel
- Developer
- Posts: 4116
- Joined: Wed Dec 10, 2003 5:26 pm
Re: nVelocity for current YEAR?
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.
Cheers,
Logan
.com
If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Logan

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.
Re: nVelocity for current YEAR?
A bit more elegant solution would be to add into the Page.Items dictionary which you have access from the template as . 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 event. The current page can be accessed there via .
Mihkel
Code: Select all
DateTime.Now()
Code: Select all
$page.Items.get_Item("currentDate").Year
Code: Select all
Application_PreRequestHandlerExecute
Code: Select all
HttpContext.Current.Handler as Page
Mihkel
Re: nVelocity for current YEAR?
I like this