I would like to know how Magento converts {{store url="example/example"}}
into http://www.example.com/example/example/
2 Answers
In Mage_Core_Model_Email_Template_Filter::storeDirective()
.
Don't be confused by the class name, Mage_Cms_Model_Template_Filter
extends from it and the basic functionality of these directives1 is in the base class Varien_Filter_Template
. Not the best class hierarchy, I know.
Look at the filter()
method in Varien_Filter_Template
, this is what is called when a CMS page or email template is rendered.
1) all the {{stuff in curly brackets}}
Mage_Core_Model_Email_Template_Filter::storeDirective
Which is called from Varien_Filter_Template::filter
and specifically the section below which matches the CONSTRUCTION_PATTERN
(stuff in double curly braces).
Then strips out the type e.g {{store url=""}}
would be store
this type is then prefixed to the word 'Directive' to form the callback method name into which the matched string is passed.
$callback = array($this, $construction[1].'Directive');
if(preg_match_all(self::CONSTRUCTION_PATTERN, $value, $constructions, PREG_SET_ORDER)) {
foreach($constructions as $index=>$construction) {
...
$callback = array($this, $construction[1].'Directive');
...
$replacedValue = call_user_func($callback, $construction);
...
$value = str_replace($construction[0], $replacedValue, $value);
}
}