PDA

View Full Version : Find and replace in postbit


Dr.CustUmz
03-16-2016, 05:32 PM
im trying to replace this string in postbit and postbit_legacy template through a plugin.

<img src="$post[avatarurl]" $post[avwidth] $post[avheight] alt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" />
the plugin is hooked to postbit_display_complete
this is what im messing around with but cant find a solution to.
$search = '<img src="$post[avatarurl]" $post[avwidth] $post[avheight] alt="<phrase 1="$post[username]">$vbphrase[xs_avatar]</phrase>" border="0" />';
$replace = '<div id="drcltrav" style="background-color:'.$color.';"><span>'.strtoupper($drcltrav_lgth).'</span></div>';
$vbulletin->templatecache['postbit'] = str_replace($search, $replace, $vbulletin->templatecache['postbit']);
$show['avatar'] = true;

can someone help me out, and how would i go about replacing it in both postbits?

MarkFL
03-16-2016, 07:01 PM
Try using the following search string:

$search = '<img src="' . $post[avatarurl] . '" ' . $post[avwidth] . ' ' . $post[avheight] . 'alt="<phrase 1="' . $post[username] . '">' . $vbphrase[xs_avatar] . '</phrase>" border="0" />';

Dr.CustUmz
03-16-2016, 07:09 PM
<hookname>postbit_display_complete</hookname>
<phpcode><![CDATA[
if ($show['avatar'] != true && $this->registry->options['avatarenabled'] && !($this->registry->userinfo['userid'] > 0 AND !$this->registry->userinfo['showavatars'])) {

$search = '<img src="' . $post[avatarurl] . '" ' . $post[avwidth] . ' ' . $post[avheight] . 'alt="<phrase 1="' . $post[username] . '">' . $vbphrase[xs_avatar] . '</phrase>" border="0" />';
$replace = '<div id="drcltrav" style="background-color:'.$color.';"><span>'.strtoupper($drcltrav_lgth).'</span></div>';
$vbulletin->templatecache['postbit'] = str_replace($search, $replace, $vbulletin->templatecache['postbit']);
$show['avatar'] = true;

}]]></phpcode>
</plugin>

still outputs
<img src="" alt="DrCustUmz's Avatar" border="0" title="DrCustUmz's Avatar">

its like the only part of the code it understands is
$show['avatar'] = true;