How to use an if clause?
How to use an if clause?
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?
Re: How to use an if clause?
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
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
if(CommerceBuilder.Common.Token.Instance.User.IsAnonymous)
{
//code block within if
}
Code: Select all
<b>
<%
if(!CommerceBuilder.Common.Token.Instance.User.IsAnonymous)
{
CommerceBuilder.Common.Token.Instance.User.UserName
}%>
</b>
Re: How to use an if clause?
That's exactly what I want , thank you very much.