Page 1 of 1

NVelocity Access Current Page

Posted: Wed Jul 14, 2010 12:49 pm
by jsmits
I want to do something with nvelocity like:

Code: Select all

#if(Page.Url = "thispage.aspx")
     <a href="thatpage.aspx">That Page</a>         
 #end
Is this possible?

Re: NVelocity Access Current Page

Posted: Thu Jul 15, 2010 5:52 am
by mazhar
This is not possible through NVelocity. Page information is not available through NVelocity scripts in AbleCommerce. You can do this stuff in some conlib that's been used on desired page or may be simply create another conlib control under conlib/custom folder. Put your desired code in new conlib control and finally use it on your scriptlet.

Re: NVelocity Access Current Page

Posted: Fri Jul 16, 2010 11:11 am
by Logan Rhodehamel
mazhar wrote:Page information is not available through NVelocity scripts in AbleCommerce.
Well, actually.... For page level stuff, what you would see in your website content scriptlets, we always provide these variables to you:

store = CommerceBuilder.Stores.Store instance
customer = CommerceBuilder.Users.User instance
page = CommerceBuilder.Web.UI.AbleCommercePage instance (inherits from System.Web.UI.Page)

So to get what you are asking, you can do it indirectly from the page instance.

${page.Request.Url}

To put it into your sample:

Code: Select all

#if(page.Request.Url == "http://mydomain/mypath/thispage.aspx")
     <a href="thatpage.aspx">That Page</a>         
#end
Or something along those lines. The NVelocity script can be quite powerful, but there is a high learning curve.

Re: NVelocity Access Current Page

Posted: Fri Jul 16, 2010 11:47 am
by jsmits
Works like a charm. Just had to add '$' in front of 'page'.

Thanks.