Friday, December 30, 2011

Magento: template tags


Magento uses its own replacement tags to render dynamic content in CMS pages, e-mail
templates, and static blocks. You might have noticed that in CMS pages and static blocks
there are some {{ double curly brace wrapped }} items with some attributes. These are
known as template tags. In this recipe, we used the store tag only while there were five other
tags. Some of the template tags are as follows:
ff Block: This creates a static block with specified ID. For example: {{block
type='core/template' template='cms/your_page.phtml'}}
ff Layout: This renders an HTML layout output for the specified layout. The
handle attribute expects the name of a layout handle. For example: {{layout
handle="default"}}
ff Media: This retrieves path of files from root/media folder. For example: {{media
url="images/logo.png"}}
ff Skin: This gets files from active theme in skin/frontend folder. For example: <img
src="{{skin url='images/media/about_us.png'}}"/>
ff Store: This creates routes and custom URLs for Magento store. For example:
{{store url="contact"}} would render the full URL for that path.
ff htmlescape: This escapes html characters as its name suggests. For example:
{{htmlescape var=""}}
ff var: This renders a variable. For example: {{var my_variable}}
ff protocol: This renders the proper protocol (HTTP or HTTPS) depending on current
context. For example: {{protocol url="www.domain.com/"}}
If you want to see the methods that handle this stuff you can have a look on app/code/
core/Mage/Core/Model/Email/Template/Filter.php.

1 comment:

  1. Websites with magento integration have been better in engaging customer interest thus increasing their sales to make more profit.

    ReplyDelete