Index: branches/RC/core/units/general/helpers/template_helper.php =================================================================== diff -u -N -r11428 -r11495 --- branches/RC/core/units/general/helpers/template_helper.php (.../template_helper.php) (revision 11428) +++ branches/RC/core/units/general/helpers/template_helper.php (.../template_helper.php) (revision 11495) @@ -30,6 +30,13 @@ */ var $_parseErrors = Array (); + /** + * Source template, that is being edited + * + * @var string + */ + var $_sourceTemplate = ''; + function TemplateHelper() { parent::kHelper(); @@ -45,6 +52,21 @@ } } + function _getSourceTemplate() + { + // get source template + $t = $this->Application->GetVar('source'); + + $cms_handler =& $this->Application->recallObject('st_EventHandler'); + /* @var $cms_handler StructureEventHandler */ + + if (!$this->Application->TemplatesCache->TemplateExists($t) && !$this->Application->IsAdmin()) { + $t = $cms_handler->GetDesignTemplate($t); + } + + $this->_sourceTemplate = $t; + } + /** * Render source template to get parse errors OR it's element locations * @@ -59,8 +81,10 @@ // 2. parse template $this->Application->InitParser(); // we have no parser when saving block content - $this->Application->Parser->Run($this->Application->GetVar('source') . $append); + $this->_getSourceTemplate(); + $this->Application->Parser->Run($this->_sourceTemplate . $append); + // 3. restore original error handler $this->Application->errorHandlers = $error_handlers; @@ -145,7 +169,7 @@ */ function _isMainTemplate() { - return $this->_blockLocation['template'] == $this->Application->GetVar('source'); + return $this->_blockLocation['template'] == $this->_sourceTemplate; } /**