Difference between revisions of "NVelocity variables available in scriptlets"
(Eliminate legacy parameter names.) |
|||
(5 intermediate revisions by 3 users not shown) | |||
Line 11: | Line 11: | ||
!Variable!!Type!!Comments | !Variable!!Type!!Comments | ||
|- | |- | ||
− | |$store | + | |$store||CommerceBuilder.Stores.Store||Reference to the current store. Available for all pages |
|- | |- | ||
− | |$customer | + | |$customer||CommerceBuilder.Users.User||Reference to the current user. Available for all pages |
|- | |- | ||
|$page ||System.Web.UI.Page||The ASP.NET page object. Available for all pages | |$page ||System.Web.UI.Page||The ASP.NET page object. Available for all pages | ||
Line 26: | Line 26: | ||
|} | |} | ||
− | In the scriptlet code you can access almost anything using the above objects. For example if you want to get the Orders for current user then $ | + | In the scriptlet code you can access almost anything using the above objects. For example if you want to get the Orders for current user then $customer.Orders will provide you that information etc. However it is '''strongly discouraged''' to use nVelocity scriptlets for anything other than controlling the display layout. |
+ | |||
+ | == Common Properties == | ||
+ | |||
+ | A sample of some of the properties commonly accessed is shown in the table below. For a full listing of all object properties, see the [[CommerceBuilder_API|API]]. | ||
+ | |||
+ | {| {{Prettytable}} | ||
+ | |- {{Hl3}} | ||
+ | !Type!!Property!!Usage | ||
+ | |- | ||
+ | |CommerceBuilder.Users.User||UserName||$customer.UserName | ||
+ | |- | ||
+ | |CommerceBuilder.Users.User||Email||$customer.Email | ||
+ | |- | ||
+ | |CommerceBuilder.Users.User||PrimaryAddress.FirstName||$customer.PrimaryAddress.FirstName | ||
+ | |- | ||
+ | |CommerceBuilder.Users.User||PrimaryAddress.LastName||$customer.PrimaryAddress.LastName | ||
+ | |- | ||
+ | |CommerceBuilder.Users.User||PrimaryAddress.FullName||$customer.PrimaryAddress.FullName | ||
+ | |- | ||
+ | |CommerceBuilder.Users.User||PrimaryAddress.Phone||$customer.PrimaryAddress.Phone | ||
+ | |} | ||
== External Links == | == External Links == | ||
* [http://www.castleproject.org/others/nvelocity/ NVelocity (castleroject)] | * [http://www.castleproject.org/others/nvelocity/ NVelocity (castleroject)] | ||
* [http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html User Guide (velocity)] | * [http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html User Guide (velocity)] |
Latest revision as of 16:21, 1 March 2012
WARNING Use NVelocity to only control the layout. Don't use it as a programming alternative otherwise it will slow down your pages. If you want to customize some logic then its better to modify the ConLib controls or create new controls to meet your requirements.
The following nVelocity variables are available in scriptlets. Some variables are available only in a particular context.
Variable | Type | Comments |
---|---|---|
$store | CommerceBuilder.Stores.Store | Reference to the current store. Available for all pages |
$customer | CommerceBuilder.Users.User | Reference to the current user. Available for all pages |
$page | System.Web.UI.Page | The ASP.NET page object. Available for all pages |
$Category | CommerceBuilder.Catalog.Category | Category object is available on category, product, webpage and link display pages and wherever a CategoryId parameter is available in URL. |
$Product | CommerceBuilder.Products.Product | Product object is available on product display pages and wherever a ProductId is available in URL. |
$Webpage | CommerceBuilder.Catalog.Webpage | Webpage object is available on webpage display pages and wherever a WebpageId is available in URL. |
$Link | CommerceBuilder.Catalog.Link | Link object is available on link display pages and wherever a LinkId is available in URL. |
In the scriptlet code you can access almost anything using the above objects. For example if you want to get the Orders for current user then $customer.Orders will provide you that information etc. However it is strongly discouraged to use nVelocity scriptlets for anything other than controlling the display layout.
Common Properties
A sample of some of the properties commonly accessed is shown in the table below. For a full listing of all object properties, see the API.
Type | Property | Usage |
---|---|---|
CommerceBuilder.Users.User | UserName | $customer.UserName |
CommerceBuilder.Users.User | $customer.Email | |
CommerceBuilder.Users.User | PrimaryAddress.FirstName | $customer.PrimaryAddress.FirstName |
CommerceBuilder.Users.User | PrimaryAddress.LastName | $customer.PrimaryAddress.LastName |
CommerceBuilder.Users.User | PrimaryAddress.FullName | $customer.PrimaryAddress.FullName |
CommerceBuilder.Users.User | PrimaryAddress.Phone | $customer.PrimaryAddress.Phone |