Magento cms page rendering {{}} variables

Where in magento are {{}} variables that are precisely replaced? File?

+4
source share
2 answers

These template variables are called template directives. Each has a different method that is responsible for its rendering. For example, the widget directive

{{widget ...}} 

the widgetDirective method is widgetDirective in the Mage_Widget_Model_Template_Filter class.

 class Mage_Widget_Model_Template_Filter extends Mage_Cms_Model_Template_Filter { ... public function widgetDirective($construction) { } ... } 

While the var directive

 {{var ...}} 

handled by varDirective

 class Mage_Core_Model_Email_Template_Filter extends Varien_Filter_Template { public function varDirective($construction) { ... } } 

Each of them is in a different class. It appears when Magento wants to add a directive, they extend the old filter class and add new directory methods. Then the class that is used to create the filter object is configured. There are, as far as I can tell, four different contexts in which Magento needs to replace template variables.

  • Directory Content

  • CMS Page Content

  • CMS Static Block Content

  • Newsletter Content

The Magento filter class attribute that will be used for this is set to

 global/catalog/content/template_filter global/cms/page/template_filter global/cms/block/template_filter global/newsletter/template_filter 

Find all of your config.xml files for <template_filter/> , and you can see which class alias is used to instantiate the filter object. (You can use ack-grep -i 'template_filter' --xml $MAGENTO or find $MAGENTO -type f -name '*.xml' -exec grep -Hn 'template_filter' {} \; to find all files in $MAGENTO containing this line).

+14
source

It looks like Mage_Cms_Block_Page::_toHtml() and Mage_Cms_Block_Block::_toHtml() calls Mage_Cms_Model_Template_Filter::filter(string) . This class and several levels of parent classes parse a string through several functions.

0
source

Source: https://habr.com/ru/post/1340006/


All Articles