The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
str_replace and apostrophes
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..): HTML Code:
{vb:raw navbits.breadcrumb} {vb:raw navbits.lastelement} PHP Code:
I tried: PHP Code:
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. |
#2
|
||||
|
||||
I think this is how I did it.
Code:
$breadcrumbs = strtr($breadcrumbs,"?`’","'''"); Code:
$breadcrumbs = htmlentities($breadcrumbs, ENT_QUOTES); |
#3
|
||||
|
||||
Thanks, I'll try that out!
edit: Nope, neither worked. The first gave me the same parse error I kept getting, and the second gave me the text itself in the page: Code:
<<!-- BEGIN TEMPLATE: navbar_breadcrumbs --> <div class="breadcrumbcontainer" style="margin-bottom:10px"> etc... |
#4
|
||||
|
||||
Your welcome.
Let me know which one works I had this problem so long ago I don't remember which one it was. I luckily remembered the code it was in though. |
#5
|
||||
|
||||
Whoops, looks like you replied while I was editing. Unfortunately, neither of those worked.
|
#6
|
||||
|
||||
Ok I got it I went and installed your mod and played till I got it.
It wont let me paste it here, So I had to put it on pastebin. http://pastebin.com/m1434e916 the forum kept parsing the &/#039/; (added slashes) |
#7
|
||||
|
||||
Thank you, thank you, Thank You!!!!
I kept seeing stuff out there about replacing the apostrophe like you did, but kept thinking I wouldn't have to do that. But, I guess that is what has to be done. Thank you very much for helping me out. (and yeah, even copy/paste parsed the line so when I first tried it, it didn't work - then I saw what it had done. ) |
#8
|
||||
|
||||
Your very welcome.
As much as you help me and others its the least I could do. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|