How to use an if clause?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
learnerbm
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Wed Sep 02, 2009 8:13 am

How to use an if clause?

Post by learnerbm » Tue Oct 06, 2009 12:23 am

Hi all, in some html pages some if clauses like "#if($customer.IsAnonymous) ..." have been used. In this sentence where is "customer" setted? I couldn't find.. I need to know this because I need an if clause in ascx html source; I have a repeater but in some cases an html tag in the repeater must be ignored. How can I apply this?

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

Re: How to use an if clause?

Post by mazhar » Tue Oct 06, 2009 2:57 am

Well the script style you mentioned above is NVelocity script. NVelocity is available in scriptlets and Email templates only not in user controls. In fact NVelocity is used to put some way to get information dynamically in static contents like scriptlet files containing static HTML. As for as user controls are concerned they are already ASP.NET constructs. So you need to manipulate with ASP.NET in user controls not with NVelocity. Now if talk about $customer and many other parameters, these parameters are set by application with respect to current context for example $customer represents current customer/user of application. Similarly you can access almost all information through ASP.NET(C#) code as well by using Token object. Token object is avilable accross complete store. For example if you want to access current user/customer of application you need to use following statement

Code: Select all

if(CommerceBuilder.Common.Token.Instance.User.IsAnonymous)
{
//code block within if
}
Now if in repeater body you want to output some tag only when customer is logged on then it would be something like

Code: Select all

<b>
<%
if(!CommerceBuilder.Common.Token.Instance.User.IsAnonymous)
{
 CommerceBuilder.Common.Token.Instance.User.UserName 
}%>
</b>

learnerbm
Ensign (ENS)
Ensign (ENS)
Posts: 8
Joined: Wed Sep 02, 2009 8:13 am

Re: How to use an if clause?

Post by learnerbm » Tue Oct 06, 2009 3:56 am

That's exactly what I want , thank you very much.

Post Reply