LifesGreatestGift
04-07-2012, 05:08 AM
What am I doing wrong? I would like to do a string replace on postbit/postbit_legacy template. Find specific code, insert my custom template after it. Here is what I have and its not working.
require_once(DIR . '/includes/class_template_parser.php');
$parser = new vB_TemplateParser('<span class="postcontrols">');
$parser->dom_doc = new vB_DomDocument($parser->fetch_dom_compatible());
$find = trim($parser->_parse_nodes($parser->dom_doc->childNodes()));
$templater = vB_Template::create('my_custom_template');
$parser = new vB_TemplateParser($templater);
$parser->dom_doc = new vB_DomDocument($parser->fetch_dom_compatible());
$replace = trim($parser->_parse_nodes($parser->dom_doc->childNodes()));
$vbulletin->templatecache['postbit'] = str_replace($find, $find . $replace, $vbulletin->templatecache['postbit']);
$vbulletin->templatecache['postbit_legacy'] = str_replace($find, $find . $replace, $vbulletin->templatecache['postbit_legacy']);
unset($find, $replace);
This is using parse_templates.
I tried this in postbit_display_complete and it doesnt work either.
$find = '<span class="postcontrols">';
$replace = vB_Template::create('my_custom_template');
$vbulletin->templatecache['postbit_legacy'] = str_replace($find, $find . $replace, $vbulletin->templatecache['postbit_legacy']);
$templater->render();
unset($find, $replace);
Any help would be appreciated.
require_once(DIR . '/includes/class_template_parser.php');
$parser = new vB_TemplateParser('<span class="postcontrols">');
$parser->dom_doc = new vB_DomDocument($parser->fetch_dom_compatible());
$find = trim($parser->_parse_nodes($parser->dom_doc->childNodes()));
$templater = vB_Template::create('my_custom_template');
$parser = new vB_TemplateParser($templater);
$parser->dom_doc = new vB_DomDocument($parser->fetch_dom_compatible());
$replace = trim($parser->_parse_nodes($parser->dom_doc->childNodes()));
$vbulletin->templatecache['postbit'] = str_replace($find, $find . $replace, $vbulletin->templatecache['postbit']);
$vbulletin->templatecache['postbit_legacy'] = str_replace($find, $find . $replace, $vbulletin->templatecache['postbit_legacy']);
unset($find, $replace);
This is using parse_templates.
I tried this in postbit_display_complete and it doesnt work either.
$find = '<span class="postcontrols">';
$replace = vB_Template::create('my_custom_template');
$vbulletin->templatecache['postbit_legacy'] = str_replace($find, $find . $replace, $vbulletin->templatecache['postbit_legacy']);
$templater->render();
unset($find, $replace);
Any help would be appreciated.