_pathTpl . $this->_layout . '/tpl_' . $this->_template . '_' . $id . '.php'); $html = str_replace($this->_renderSearch, $this->_renderReplace, $html); $subTpl = new DOMDocument (); $subTpl->preserveWhitespace = false; $subTpl->formatOutput = true; $subTpl->loadHTML($html); $xpath = new DOMXpath ($subTpl); $subCont = $xpath->query(".//*[contains(concat(' ', @class, ' '), ' " . $id . " ')]")->item(0); foreach ($popupData as $singleData) { $tmp_node = $subCont->firstChild->cloneNode(true); if (isset ($singleData['id'])) { $subCont->setAttributeNode(new DOMAttr ('id', $type . '_' . $singleData['id'])); } foreach ($singleData as $key => $data) { $nodeList = $xpath->query(".//*[contains(concat(' ', @class, ' '), ' " . $key . " ')]", $tmp_node); if ($nodeList->length !== 0) { foreach ($nodeList as $node) { switch ($key) { case 'link' : $node->setAttributeNode(new DOMAttr ('href', $data)); break; default : $node->appendChild(new DOMCdataSection ($data)); break; } } } } $subCont->appendChild($tmp_node); } $subCont->removeChild($subCont->firstChild); $new_node = $this->_tpl->importNode($subCont, true); return $new_node; } }