MyBB Community Forums

Full Version: Template Include Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Heloo there,

I've been working on plugin, it simply adds a line to the index template, it was working ok, however the only problem i faced is the INCLUDE

it's like doubling the code i'm adding, once in the designated place, and a sec time between <head> </head> so when i browse the board, i will get them twice over there, and between them the word INCLUDE

like if i add a photo, beside the welcome panel, i will get the logo along with the nav bar, and the welcome panel, twice and in btween the word INCLUDE.

to illustrate about the pluing, read this Thread.


many thanks
Well you should use "include_once()" and "require_once()" that might solve the problem. But what I think is happening is that when the plugin is deactivated, it isn't removing the old code. Activate it again and it's adding another copy of the HTML in.

Deactivate your plugin, go to the template you edit and revert all code back to the original. Activate, check it works, deactivate and make sure it is deleted from the template. I don't think it is being deleted?

If I am right (not too sure) then it's because the string you are looking for in your deactivation function isn't preg_quoted, or a preg_replace string at all.
function bar_deactivate()
{
require "./inc/adminfunctions_templates.php";
find_replace_templatesets("index", '<table width="100%" cellspacing="$theme[borderwidth]">
<tr>
<td valign="top" align="right">
<div class="bottommenu"><span class="smalltext">$logoutlink
</td>
</tr>
</table>#', "", 0);

}
The string beginning with <table width="100%" doesn't have a '#' at the start (has one at end), and you should put the actual string (not the #) in a preg_quote($my_string) function.

Of course I could be wrong, I was in the other thread Wink.
heloo there,

no it's not that it's adding it self, i have reset it each time i apply it .

i'm intrestested in the includeonce...
is it that i have to update this > require "./inc/adminfunctions_templates.php";

or it's a seperate code ?

thx
It's the same thing. It's just that include_once or require_once will only include the file once. Otherwise if you include a file twice, it might execute the same code twice = duplicate HTML. But I don't think this is the case here.
Yes you can just update your code with require_once instead of just require.
hey there

i used require_once "./inc/adminfunctions_templates.php";

but still giving that include

thx