Lynne
12-02-2009, 10:28 PM
I wrote a mod to put the breadcrumbs at the bottom of the showthread page. It works just fine except when either the forum title or thread title has an apostrophe in it. Basically, I copied the breadcrumb portion of the navbar and put it in it's own template, render the template, then do a str_replace on it and then get an error if there is an apostrophe in it. I've tried all sorts of things to get this to work (addslashes then stripslashes, not using a template for the breadcrumb code) and just can't get it to work in anyway except to use a template_hook (which would be great except there isn't a template hook where I want one!).
Basic code:
Template, navbar_breadcrumbs, that has (a bunch of stuff, including..):
{vb:raw navbits.breadcrumb}
{vb:raw navbits.lastelement}A plugin:
$newTemplate = vB_Template::create('navbar_breadcrumbs');
$newTemplate->register('navbits', $navbits);
$breadcrumbs = $newTemplate->render();
$find = '<div id="thread_info">';
$vbulletin->templatecache['SHOWTHREAD'] = str_replace($find,$breadcrumbs.$find, $vbulletin->templatecache['SHOWTHREAD']);That doesn't work.
I tried:
$breadcrumbs = addslashes($newTemplate->render()); And, as expected, I get output with quotes escaped.
I've added in stripslashes for the whole preg_replace, for just the 'replace' part, I've done addslashes to each item and then stripslashes to the whole thing. It just isn't coming out right. As I said, I can do a template_hook (and probably will), but I have a feeling it's something real simple and now I'm really curious about how this might work anyway and just wanna know if there is some easy solution I just haven't hit on.
Basic code:
Template, navbar_breadcrumbs, that has (a bunch of stuff, including..):
{vb:raw navbits.breadcrumb}
{vb:raw navbits.lastelement}A plugin:
$newTemplate = vB_Template::create('navbar_breadcrumbs');
$newTemplate->register('navbits', $navbits);
$breadcrumbs = $newTemplate->render();
$find = '<div id="thread_info">';
$vbulletin->templatecache['SHOWTHREAD'] = str_replace($find,$breadcrumbs.$find, $vbulletin->templatecache['SHOWTHREAD']);That doesn't work.
I tried:
$breadcrumbs = addslashes($newTemplate->render()); And, as expected, I get output with quotes escaped.
I've added in stripslashes for the whole preg_replace, for just the 'replace' part, I've done addslashes to each item and then stripslashes to the whole thing. It just isn't coming out right. As I said, I can do a template_hook (and probably will), but I have a feeling it's something real simple and now I'm really curious about how this might work anyway and just wanna know if there is some easy solution I just haven't hit on.