Quote:
Originally Posted by Boofo
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.
|
I tried with and without. There's an article here on vB.org that stresses that you have to escape double quotes because that's the way the code is stored in memory:
Quote:
Originally Posted by mfyvie
Code:
$find = '<table class=\"tborder\" cellpadding=\"$stylevar[cellpadding]\" cellspacing=\"$stylevar[cellspacing]\" border=\"0\" width=\"100%\" align=\"center\" id=\"woltable\">';
This is what we are going to look for, we've stored it in a variable called $find to make it easier to handle. Did you notice something? We've changed things slightly. Every time we have a double quote we need to " escape" it. We do this by adding a backslash character to tell PHP that we really do want a double quote stored in the variable, rather than having PHP think that we are ending or beginning a string using the double quote character. We've also enclosed our string in single quotes. Now you might be saying that at this point "But single quotes mean I don't have to escape double quotes". This is true, but not in this case. If we actually looked inside the template, as it is stored in memory, we'd find those backslash characters. If we want our search to match, we have to put them in. We could have also used the addslashes() function to do this, but we are keeping this example simple, so we put them in by hand. Remember what you see when editing the template via the style manager is not always the same as what is actually stored in memory!
|
Nevertheless, I'm always game, especially since the article is a few years old and I tried the code you sent me. In fact, I tried this same method (with and without quotes) before I tried using a template.
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']);
I keep picking different hooks, but nothing seems to work, and it seems like it should.
Quote:
Originally Posted by Boofo
And this I have never seen before:
Quote:
fetch_template(djs_delete_link)
|
|
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.