The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Using str_replace in MEMBERINFO
I've been searching for a few days, and I can't find anything to suggest why str_replace isn't working in MEMBERINFO for me. I've tried using both a custom template and simply putting the replacement code in a variable. I can' tell if I'm using the wrong hook, using outdated code or what.
For example, using a custome template Code:
$find= '<li class=\"thead\"><a href=\"moderator.php?$session[sessionurl]do=useroptions&u=$userinfo[userid]\">$vbphrase[edit_user_profile]</a></li>'; $vbulletin->templatecache['MEMBERINFO'] = str_replace($find, fetch_template(djs_delete_link) . $find, $vbulletin->templatecache['MEMBERINFO']); |
#2
|
||||
|
||||
You don't escape double quotes when they are used between single quotes. Only single quotes get escaped between single quotes. That is why it is not working for you.
And this I have never seen before: Quote:
|
#3
|
||||
|
||||
Quote:
Quote:
Code:
$find = '<li class="thead"><a href="moderator.php?$session[sessionurl]do=useroptions&u=$userinfo[userid]">$vbphrase[edit_user_profile]</a></li>'; $add_before = '<li class="thead"><a href="admincp/user.php?do=remove&u=$userinfo[userid]" style="color:red; font-face:bold">Delete User Profile</a></li>'; $vbulletin->templatecache['MEMBERINFO'] = str_replace($find, $add_before . $find, $vbulletin->templatecache['MEMBERINFO']); Is there a more current way to fetch a template? That article is from 2007, but I've not been able to find anything more current. At least not for vB3. |
#4
|
||||
|
||||
I meant you can't fetch a template in the middle of a str_replace, AFAIK. Also, this is one of the lines I have in one of my mods for a str_replace:
HTML Code:
$find2 = '<input type="checkbox" name="cookieuser" id="cb_cookieuser" value="1" tabindex="1" />';
I don't escape the double quotes and it works fine. |
#5
|
||||
|
||||
Quote:
|
#6
|
||||
|
||||
I believe you. You're not crazy.
|
#7
|
|||
|
|||
I read the first post and also thought for sure it was the backslashes. Anyway, to see what was going on I put this code in a plugin using member_complete:
PHP Code:
PHP Code:
It also looks like you should need the backslashes, but then I can't explain why Boofo's example works, so . Anyway, I guess you could probably make the $find be only the part before $session (or match something before that line instead if that doesn't narrow it down). Maybe you could put an html comment in the right place just to have something to match. ETA: ...or maybe you could just copy the line as it appears above and use that. |
#8
|
||||
|
||||
Then he would also have to do the replace line parsed. The only way to know what that is is to manually add the code to the template first and then go to the db and look at the template code for that after it is parsed and use that for the replacement. I used to do it that way at one time.
The escaped backslashes are there after it is the db, not before. Look at the Delete User Link in Profile mod I just did and see how I had to do it for vb 4. vb 3 was a lot easier to str_replace. |
#9
|
||||
|
||||
That would explain a lot. Just tried adding it to the template and it looks like this:
PHP Code:
|
#10
|
||||
|
||||
The 1 character causing the whole thing not to match is the ? after "moderator.php" - everything before it and everything after it (with kh99's code) matches.. and all the double quotes must be escaped as well, I tried it and it didn't work without escaping them, though I agree with Boofo it's not logical this needs to be done.
But anyway the code I have the replacement working on is on hook member_start. This code works fine: PHP Code:
PHP Code:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|