As explained in Where is the code for "{{store url="example/example"}} {{store}}
is one of the so-called template directives used by CMS and transactional emails
It is documented as follows:
/**
* Retrieve store URL directive
* Support url and direct_url properties
*/
So, "store" is short for "store url" and refers to an URL in the store, that means a link within the store. It automatically adds the correct base URL (important for email templates where you cannot use relative links) and resolves some other parameters (see below)
How to use it
You can pass it a route, just as you would with Mage::getUrl()
:
{{store url="customer/account/login"}}
Also with parameters:
{{store url="catalog/product/view" id="42"}}
Or query parameters, for example to add filters in the layered navigation:
{{store url="catalog/category/view" id="3" _query_color=red}}
=> example.com/url-to-category-3/?color=red
If you want to specify an arbitrary URL instead, use direct_url
, this way Magento only adds the base URL and leaves the given URL as it is:
{{store direct_url="terms.html#delivery"}}
Other URL directives are
{{skin url="..."}}
for URLs to images, JavaScript or CSS within the current theme, using the theme fallback mechanism.
{{media url="..."}}
for URLs to images or other media in the media directory (default: /media/
)
{{protocol url="www.domain.com/"}}
for arbitrary external URLs, but with the current protocol (http or https)
{{protocol http="http://url" https="https://url"}
to show different URLs dependend on the current protocol
{{protocol}}
to just output "https" or "http"
Other non-URL directives
{{config path="..."}}
outputs a configuration value
{{customvar code="..."}}
outputs a custom variable (globally maintained in System > Custom Variables)
{{htmlescape var="..." allowed_tags="..."}}
converts special characters in the text, given in "var" to HTML entities. The optional "allowed_tags" parameter can contain a comma separated list of tags that should be kept intact (for example "h1,h2,strong,em"). It is most useful in email templates because you can pass a template variable: like this: {{htmlescape var=$customer.firstname}}
{{inlinecss file="..."}}
loads CSS from a file and adds it as inline style sheet. Useful for emails.
{{block type="..." id="..." output="..." ...}}
instantiates and renders any Magento block type
{{layout area="..." handle="..." ...}}
loads an entire layout handle (defined in the layout XML files) and renders its first block. Additional parameters are passed to all blocks.
Note that custom variables and blocks must be whitelisted before they can be used. See:
APPSEC-1057 How to add variables or blocks to the white list tables
Other non-URL directives (Email Templates only)
{{var X}}
, {{var X.y()}}
output template variable X / result of method y() on variable X. See Template vars/placeholders
{{depend X}}...{{/depend}}
output content in between only if variable X is true-ish (note that you cannot use logical expressions here, just variables or methods on variables.
{{if X}}...{{else}}...{{/if}}
the same but with an optional "else" block.
{{template config_path="..."}}
include another email template based on a configuration value, for example "design/email/header". By default, the "header" and "footer" email templates are included in all other email templates.
{{include template="..."}}
includes another template. This template will inherit all template variables from the current one and you can pass additional parameters with name="value"
.
Variables in parameters
Anything that can be processed by {{var}}
(see above), can also be used as parameter for another directive, with the following syntax:
{{store url=$x}}
{{store url=$x.y()}}
Limitations
You cannot nest {{if}}
and {{depend}}
directives:
{{if x}}{{depend y}} THIS WORKS {{/depend}}{{/if}}
{{depend x}}{{if y}} THIS WORKS {{/if}}{{/depend}}
{{depend x}}{{depend y}} DOES NOT WORK {{/depend}}{{/depend}}
{{if x}}{{if y}} DOES NOT WORK {{/if}}{{/if}}
You cannot use directives in parameters of other directives. For example:
{{store url={{config path="..."}}}}
does not work
Where to find these directives/parameters
The class Mage_Core_Model_Email_Template_Filter
is responsible for parsing most of the attributes specified in CMS directives ({{
). This class is commonly inherited from other classes like Mage_Widget_Model_Template_Filter
and Mage_Cms_Model_Template_Filter
.
For example: Mage_Core_Model_Email_Template_Filter::storeDirective
, Mage_Core_Model_Email_Template_Filter::skinDirective
, Mage_Core_Model_Email_Template_Filter::htmlescapeDirective
and so on.
There you can see what attributes you can specify. For example in the skinDirective
method:
public function skinDirective($construction)
{
$params = $this->_getIncludeParameters($construction[2]);
$params['_absolute'] = $this->_useAbsoluteLinks;
$url = Mage::getDesign()->getSkinUrl($params['url'], $params);
return $url;
}
So we can use: {{skin url="someimage.jpg" _theme="default" _package="default" _area="frontend"}}
{{if order.customer_group_id == 1}} <p>Test Code</p> {{/if}}