PDA

View Full Version : Small problem... My plugin keeps repeating itself...


4x4 Mecca
06-09-2008, 02:51 PM
What I mean is, I have a plugin that is supposed to replace something in the postbit with additional info, but it repeats that additional info more for each poster in the thread, so for example their post count looks like this

Posts: 125!

next user

Posts: 36,588!!

Next user

Posts: 16!!!

and so on adding more ! every time, here is the code, and I'm using postbit_display_complete because it's the only one that actually even inserts the data. Thanks for your help
$stuff="!";
$lookfor='$vbphrase[posts]: $post[posts]';
$replace='$vbphrase[posts]: $post[posts] $stuff';
$vbulletin->templatecache['postbit_legacy'] = str_replace($lookfor, $replace, $vbulletin->templatecache['postbit_legacy']);

Opserty
06-09-2008, 03:04 PM
The template cache only needs to be edited once... you are editing it each time the postbit is displayed. Find another hook location for the plugin, e.g. showthread_start or something. (One that does not get repeated).

4x4 Mecca
06-09-2008, 03:09 PM
it works now, I moved everything from the $replace section into the $stuff section and it works great.

Opserty
06-09-2008, 03:28 PM
But your code only needs to be executed once, you are executing it each time the postbit is displayed.

4x4 Mecca
06-09-2008, 06:20 PM
thanks, I will try another hook.

--------------- Added 1213039449 at 1213039449 ---------------

i have tried about 7 different hooks, this is the only one that shows the info.

Opserty
06-10-2008, 06:56 AM
Hmm what hooks did you try? Did you try showthread_start as I suggested? (By only "shows the info", do you mean only one that shows the changes the plugin makes?)