NVelocity Access Current Page

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
jsmits
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Wed Sep 30, 2009 11:57 am

NVelocity Access Current Page

Post by jsmits » Wed Jul 14, 2010 12:49 pm

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?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: NVelocity Access Current Page

Post by mazhar » Thu Jul 15, 2010 5:52 am

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.

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: NVelocity Access Current Page

Post by Logan Rhodehamel » Fri Jul 16, 2010 11:11 am

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.
Cheers,
Logan
Image.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.

User avatar
jsmits
Lieutenant (LT)
Lieutenant (LT)
Posts: 66
Joined: Wed Sep 30, 2009 11:57 am

Re: NVelocity Access Current Page

Post by jsmits » Fri Jul 16, 2010 11:47 am

Works like a charm. Just had to add '$' in front of 'page'.

Thanks.

Post Reply