Search This Blog

Jun 23, 2011

List of Magento Code Directives

If you are a Magento user / developer you definitely try to edit / add CMS pages and you probably encountered special {{magentocodedirective}} syntax. This syntax is usually used to create blocks and CMS pages. These primarily used to retrieve specific values using replacement codes.
Here are some commonly used replacement code / magento directive code


1. MediaDirective
- Like skinDirective, it is used to retrieve the media url / folder
Example.
{{media url=’image.jpg’}}
Params:
url = empty or relative file path

2. Skin Directive
- It is used to retrieve the skin url
Example.
{{skin url=’images/sample.jpg’ }}
Params:
url = empty or relative file path
_theme = alternative theme, fallbacks if file not exist
_package = alternative package
_area = alternative area(frontend,adminhtml)
_type, _default

3. Htmlescape Directive
- It is used to escape special html characters like “<”, “>” etc.
Example: 
{{htmlescape var=’<a href=”www.webdosh.net”> webdosh </a>’}}
Params:
var = string to escape
allowed_tags = comma-separated list of allowed tags

4. Store Directive
- it is use to construct magento routes and custom urls
Example: 
{{store url=’customer/account’}}
Params:
url = magento routers url
direct_url = normal url, appended to baseurl
_query_PARAMNAME = adds query param,
_fragment = adds fragment
_escape = escapes “,’,<,>
custom = if using magento route url param

5. Block Directive
It is used to print out cms static block that defined by block type
Example:
{{block id=”static_block_code”}} – static block example
Params:
id = static block code; if id is set type is always cms/block
type = block type

6. Layout Directive
It is used to print the layout handle defined in xml files on layout folder.
Example:
{{layout area=”frontend” handle=”layout_handle”}}
Params:
area = frontend or adminhtml
handle = layout handle

7. Customvar Directive
Use to prints out Custom Variable HTML Value (System->Custom Variables in admin).
Example
{{customvar code=”my_custom_var”}}
Params:
code = custom variable code

8. config Directive
Use to print magento config value.
Example:
{{config path=”general/store_information/address”}}
Params:
path = config path

9. Widget Directive
Use to print out defined widget. 
Example
{{widget type="catalog/product_widget_new" products_count="5" template=”catalog/product/widget/new/content/new_list.phtml”}}
Params:
type = widget type
name = determine what name block should have in layout

10. Protocol Directive
Used to print current protocol for an absolute path.
Example:
{{protocol}} – current protocol http or https
Params:
url =  print with proper protocol prefix
http + https = prints out https value if viewing secure page
store = optional store id to check secure by that store; I’m not exactly sure what’s the purpose of this

0 comments: