_pathTpl . $this->_layout . '/tpl_' . $this->_template . '_widget_' . $widgetData['tpl'] . '.php'); $html = str_replace($this->_renderSearch, $this->_renderReplace, $html); foreach ($widgetData as $key => $value) { $html = str_replace('%%' . $key . '%%', $value, $html); } $subTpl = new DOMDocument (); $subTpl->preserveWhitespace = false; $subTpl->formatOutput = true; $subTpl->loadHTML($html); $xpath = new DOMXpath ($subTpl); $subCont = $xpath->query(".//*[contains(concat(' ', @class, ' '), ' " . $widgetData['tpl'] . " ')]")->item(0); if (isset ($widgetData['id'])) { $subCont->setAttributeNode(new DOMAttr ('id', 'widget_' . $widgetData['id'])); } $new_node = $this->_tpl->importNode($subCont, true); return $new_node; } }