Theme view helpers and modifiers

Notando eCommerce template engine is based on Smarty template engine with ability of using Zend View helpers. You can use the functionality that you prefer, or both.

All Smarty template engine features such as: varaible modifiers, built-in and custom functions are available. They described at Smarty template engine documentation.

Please note, if you are using additional modifiers as Zend View Helpers use camel case functions naming. For example instead of {$this->zend_debug($var)} you should use {$this->zendDebug($var)}

When use Zend View helper, you should write: {$this->helper()} instead of <?php echo $this->helper()?>

Variable modifiers

You can use common Smarty variable modifies, additional varible modifies provided by Notando engine and some php functions allowed to use as smarty modifies either. All additional modifiers are also available as Zend View Helpers. For example {'Text to translate'|lang} and {$this->lang('Text to translate')} are both correct.

To provide webshop engine security not all php functions are avaiable as modifers. You are able to use the following: count, strpos, strropos, intval, floatval, json_encode, json_decode, implode, explode, trim, html_entity_decode, htmlentities, htmlspecialchars_decode, htmlspecialchars, join, lcfirst, ltrim, nl2br, strip_tags, addslashes, stripcslashes, strlen, strtolower, strtoupper, ucfirst, ucwords, date_format, date, strtotime, jsonEncode, jsonDecode .
Please note, this functions are not accessable as Zend View Helpers.

Additional variable modifiers list

Modifier Description
productLink This is used to create product link.

Parameters:

  1. category_id - id of current product category

Example:

<a href="{$product|productLink:$category_id}">{$product->name}</a>

Zend View Helper syntax example:

<a href="{$this->productLink($product, $category_id)}">{$product->name}</a>
lang This is used to get translated version of a string. If additional parameters exists they will be passed as arguments for sprintf() php function.

Example:

part of .po file:
msgid "String to translate"
msgstr "Translated string"

msgid "%s, you have %d items in your cart."
msgstr "%s, you have %d items in your cart."
template:
{'String to translate'|lang}
{'%s, you have %d items in your cart.'|lang:'User':3}
will output:
Translated string
User, you have 3 items in your cart.

Zend View Helper syntax example:

{$this->lang('String to translate')}
{$this->lang('%s, you have %d items in your cart.', 'User', 3)}
numberFormat This formats a number into the given number format.

Parameters:

  1. type (required) - Notando number format type. Available formats are: webshop_amount, ... Default is webshop_amount
  2. positive - ???

Example:

{10.5|numberFormat:'webshop_amount'}
will output, if webshop_amount set to 2 digits after dot:
10,50

Zend View Helper syntax example:

{$this->numberFormat(10.5)}
zend_debug This will output dump of a variable with Zend_Debug::dump().

Example:

<?php
//Controller code
$this->view->test_array = array(1, 2, 3);
?>

{*Template code*}
{$test_array|zend_debug}

Zend View Helper syntax example:

{$this->zendDebug($test_array)}

Template specific modifiers

When including resources or template files you must use theme modifiers, for example:

{'images/list_no_product_image.png'|selectable_resource}
{include file='controllers/login/index.phtml'|theme_template}
Using resourses without theme modifiers is wrong because resources and template absolute paths is different for each company.(Requirement to use modifies does not concern adding templates as content blocks by means of the rules in blocks.xml file)



Modifier Description
selectable_resource This is used for including theme resources. If resource wasn't found in current theme resources folder - file from default theme will be included. Use relative to resources folder path for resource files.

Example:

{'images/list_no_product_image.png'|selectable_resource}
this code will include images/list_no_product_image.png from theme resources folder. If file does not exists in theme resources folder it will include this file from default theme resources folder.

Zend View Helper syntax example:

{$this->selectableResource('images/list_no_product_image.png')}
theme_resource This is used for including theme resources. With this modifier only theme resources will be included. This modifier has to be used in your custom themes. Use relative to resources folder path for resource files.

Example:

{'js/lightbox.js'|theme_resource}
this code will include js/lightbox.js from theme resources folder.

Zend View Helper syntax example:

{$this->themeResource('js/lightbox.js')}
theme_template This is used for including theme templates. If template wasn't found in current theme templates folder - file from default theme will be included. Use relative to templates folder path for template files.

Example:

{include file='controllers/login/index.phtml'|theme_template}
this code will include controllers/login/index.phtml template resources folder.

Zend View Helper syntax example:

{$this->themeTemplate('controllers/login/index.phtml')}
Using of Zend View Helper syntax is possible but not recommended.

Custom functions

All custom functions are also available as Zend View Helpers.

Function Description
pager This is used to render pager.

Parameters:

  1. pager_adapter (required) - instance of Notando_Pager.
  2. pager_path - URI
  3. target - link target attribute value.

Example:

{pager pager_adapter=$order_history_pager}

Zend View Helper syntax example:

{$this->pager($order_history_pager)}
display_specials This is used to display specials CMS content.

Parameters:

  1. shortcut (required) - specials shortcut name.

Example:

{display_specials shortcut="main_page"}

Zend View Helper syntax example:

{$this->displaySpecials('main_page')}
payment_system_logo This is used to display payment system logo with payment system info.

Parameters:

  1. info (required) - payment system info object.

Example:

{payment_system_logo info=$paymentMethod}

Zend View Helper syntax example:

{$this->paymentSystemLogo($paymentMethod)}