Introduction
This tutorial shows how to use Velocity code on your catalog to use more then one item template for you add to cart buttons . This velocity code example is intended to be used within the catalog templates section of UltraCart.
Sample Code
Part 1: Item Template code
If / Else Template : #if ($parameters.get("view") == "quick") #ucTemplate("template_item_quick") #else #ucTemplate("template_item_full") #end
Break Down
Condition 1
#if ($parameters.get("view") == "quick") #ucTemplate("template_item_quick")
This is stating that if the parameter of "view" is set to "quick" then us the following template. If this is not true then us the following
Condition 2
#else #ucTemplate("template_item_full") #end
So if the parameter of "view" is not set to "quick" then this statement is used to display the "template_item_full" template.
Sample Code
Part 2: Item Links
Links
Parameter link: View Link: <a href="${columnUrl}?view=quick">View Item</a> Full Template Link: View Link: <a class="view_item cart_button" href="$columnUrl" title="View Item">View Item</a>
This code can be used on a group page as follows:
#if($item.getAttribute("Quick")) <a href="${columnUrl}?view=quick">View Item</a> #else <a class="view_item cart_button" href="$columnUrl" title="View Item">View Item</a> #end