On this page i’m gonna put all the template stuff someone will need to make a template: different global variables, loops, condition statements and other smarty-related stuff.
Let’s start from different variables:
{$config.skin_path} – the root path of the skin, i.e. cs-cart/skins/myskin/customer
{$config.current_url} – contains the current url
{$index_script} – contains the path to index.php (or admin.php if it’s a template for admin page)
{$images_dir} – the /images/ directory of the skin
{$images_dir}/{$manifest.Customer_logo.filename} – this will generate an url to the logo
{$manifest.copyright} – contains the copyright info from the template file manifest.ini
{$manifest.copyright_url} – copyright url from the template file manifest.ini
{if $auth.user_id} – may be used to check if user logged in
{if $hide_advanced_search} – used to check if advanced search is on
{if $location_dir==”blocks/locations/index”} – used to check if it’s home page
{$smarty.const.TIME|date_format:”%Y”} – display current year
{$smarty.session.cart.amount} – used to check or output the number of items on the cart
{$smarty.session.cart.display_subtotal} – total price of all items in cart
{$smarty.session.cart.products} – an array of products in cart
{$ldelim} – will output the raw { symbol
{$rdelim} – will output }
Useful commands and constructors
{assign var=”product” value=1|fn_get_product_data} – this will set a $product variable with the info of product with id 1. (You may need to enclose this in {capture} to make sure it doesn’t echo any errors if there are)
Template Loops:
{foreach from=0|fn_get_subcategories item=”cat”}…{/foreach} – iterate through categories, if you place another foreach inside of current, it will allow to iterate through child categories too
{$cat.category|escape:html} – outputs category title and escapes html symbols
{assign var=”_cart_products” value=$smarty.session.cart.products|array_reverse:true}
{foreach from=$_cart_products key=”key” item=”p” name=”cart_products”}
…
{/foreach} – this loop is used to loop through cart items
File-related commands:
{include file=”common_templates/search.tpl” hide_advanced_search=true} – includes the file search.tpl (default search template) with hiding the advanced search option
{script src=”js/myscript.js”} – this will place the <script> tag with all the neccessary attributes
Some general dispatch paths:
categories.catalog – catalog view (a list of categories usually displayed with images and a list of subcategories in it)
pages.view&page_id=1 – display page with id 1
products.search – search page
profiles.add – user registration page
profiles.update – user profiles page
promotions.list – page with promotions
