Page 1 of 1

custom link on default header page

Posted: Wed Sep 17, 2008 9:29 am
by mshaw
I have tried placing some code in the scriptlet to show a custom link if the user is coming from a certain url but it does not render correctly.
Here is the code:
<% if (Request.UrlReferrer.ToString().Contains("testexchange"))
{
Response.Write("<a href='http://www.exchangeonlinemall.com/defau ... =aafes.com' class='tab'>Return to Mall</a>")

}%>
I have also tried it like this:
# if (Request.UrlReferrer.ToString().Contains("testexchange"))
{
Response.Write("<a href='http://www.exchangeonlinemall.com/defau ... =aafes.com' class='tab'>Return to Mall</a>")

}
#end

Any help is appreciated. Thanks

Re: custom link on default header page

Posted: Wed Sep 17, 2008 10:32 am
by nickc
Mmm. Can't put asp markup in scriplets - they are .htm files and not rendered that way.
I'd approach this by creating a custom control, say "LinkExchange.ascx", to inspect the origin page and write the appropriate link as an anchor tag, then inject the control in the header.htm as [[ConLib:Custom\LinkExchange]]. More concise in the htm and all the yummy goodness of C# code behind.
Also, Able does rewrites extensively; it's unlikely that Request.UrlReferrer is what you expect. Fortunately they preserve what you are looking for in Session["SessionReferrerUrl"] (Global.asax).

Re: custom link on default header page

Posted: Thu Sep 18, 2008 1:06 am
by mazhar
As nickc said you can't add ASP.NET code to the scriptlets. The better approach will be to create a new user control and handle all ASP.NET stuff in that control and then place it here on the page where you want to have that functionality.
You can't do this using NVelocity because AbleCommerce does support NVeleocity code for some specific Able objects only, not for the ASP.NET constructs.

Re: custom link on default header page

Posted: Thu Sep 18, 2008 11:27 am
by nickc
Hey Mazhar,

I was wondering about that. Is there any way to extend the objects available to the nVelocity engine, or are they defined in the DLL? It looks like a more typical implementation of the engine gives access to Request, Session, etc...