Template¶
Variable used in template¶
Global variable: $vnc can be access in any (.tpl) files.
{% if vnc %}
{% if vnc.getVar('product') %}
<h3>{{ vnc.getVar('product').name }}</h3>
{% elseif vnc.getVar('category') %}
<h3>{{ vnc.getVar('category').name }}</h3>
<p>{{ vnc.getVar('category').description }}</p>
{% elseif vnc.getVar('blog_category') %}
<h1>{{ vnc.getVar('blog_category').name }}</h1>
<p>{{ vnc.getVar('blog_category').description }}</p>
{% elseif vnc.getVar('blog_entry') %}
<h1>{{ vnc.getVar('blog_entry').entry_title }}</h1>
{# elseif vnc.getVar('blog_author') %}
<h1>{{ vnc.getVar('blog_author') }}</h1>
#}
{% elseif vnc.getVar('heading_title') %}
<h3>{{vnc.getVar('heading_title') }}</h3>
{% else %}
<h3>Empty</h3>
{% endif %}
{% endif %}
Get any block content in page.tpl (except parent block (column_left, ..))
//parent block, child block index: deprecated
{# vnc._view.loadBlock('header_bottom', 0) #}
{{ registry.get('_view').loadBlock('footer_top', 1) }}
#or short form using
{{ loadBlock('header_bottom', 0) }}
//get variable data from any block/page. note: make sure this block already loaded
{{ blockVar('blocks/bestseller','var1') }}
{% set categories = blockVar('pages/product/category', 'categories') %}
//or
{{ registry.get('_view').blockVar(..) }}
//for block
blockVar('blocks/bestseller', 'products')
Template tag
common template tag:
{% if is_admin() %}
is_home()
is_category()
is_single_product()
is_manufacturer()
is_generic_pages()
is_search()
is_ajax()
is_page('content/contact')
Model
Access model.
getModel('catalog/product').getProduct('<ID>')
Components.
In addition to the blocks available in the layout, we allow loading of blocks without adding to the layout. Display element as comment, ..
{{ loadView('comment') }}
{{ loadView('social_button') }}
Form Field.
{% set btn = review_button.vnc_getProperty('data') %}
<button class="button submit" title="{{ btn.title? btn.title : btn.text }}" type="submit">{{ btn.text }}</button>
# other way
<button class="button submit" title="{{ fieldValue(review_button,'title','text') }}" type="submit">{{ fieldValue(review_button,'text') }}</button>
Debuging:
//buitin function help you print value of any variable
{{ _print(..) }}
{{ _debug_backtrace(debug_backtrace()) }}
URL:
{{ html.getSEOURL('account/wishlist') }}
{{ html.getURL('account/wishlist') }}
{{ html.getSecureURL('account/wishlist') }}
{{ html.getHomeURL() }}
Customer:
//wishlist count
{{ customer.getWishList()|length }}
User
//current user
{{ current_user() }}
Utils functions
String:
//replace string at first found
str_replace_first($find, $replace, $object)
Config:
config.get('store_main_email')
{{ config.get('livechat_embed') }}