mfyvie
06-01-2007, 10:11 AM
I'm using str_replace to try and get a plugin to modify a template. This in itself is not a problem, but as soon as I add in a conditional, it doesn't seem to be parsed when the template is run.
Here's what I'm trying to do:
$disabled_add = ' $disabled /><if condition=\"$disabled==\"disabled\"\"><span style=\"color: grey\">$vbphrase[avatar_taken]</span><else />$avatar[title]</if>';
$vbulletin->templatecache['modifyavatarbit'] = str_replace(' />$avatar[title]', $disabled_add, $vbulletin->templatecache['modifyavatarbit']);
note that I had to use a backslash before the double quotes otherwise all sorts of php errors were being produced.
When we look at the output we see that the conditional statements, instead of being evaluated are finding their way into the HTML output:
<input type="radio" name="avatarid" value="1880" id="rb_avatarid_1880" /><if condition="=="disabled""><span style="color: grey">Taken</span><else />Sup29</if> </label>
If I insert the changes directly into the template (without the backslash quoting of course) then the conditionals work as expected.
My guess is that conditionals inserted via str_replace aren't being evaluated correctly. Is this a bug, or does anyone know of any work-arounds. I've tried to find other mods that do this but so far haven't found any. A search of this forum and google has also proved fruitless.
Any help would be appreciated
Here's what I'm trying to do:
$disabled_add = ' $disabled /><if condition=\"$disabled==\"disabled\"\"><span style=\"color: grey\">$vbphrase[avatar_taken]</span><else />$avatar[title]</if>';
$vbulletin->templatecache['modifyavatarbit'] = str_replace(' />$avatar[title]', $disabled_add, $vbulletin->templatecache['modifyavatarbit']);
note that I had to use a backslash before the double quotes otherwise all sorts of php errors were being produced.
When we look at the output we see that the conditional statements, instead of being evaluated are finding their way into the HTML output:
<input type="radio" name="avatarid" value="1880" id="rb_avatarid_1880" /><if condition="=="disabled""><span style="color: grey">Taken</span><else />Sup29</if> </label>
If I insert the changes directly into the template (without the backslash quoting of course) then the conditionals work as expected.
My guess is that conditionals inserted via str_replace aren't being evaluated correctly. Is this a bug, or does anyone know of any work-arounds. I've tried to find other mods that do this but so far haven't found any. A search of this forum and google has also proved fruitless.
Any help would be appreciated