MyBB Community Forums

Full Version: What's wrong with this plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
hey guys , i was making a simple plugin,

anythin wrong in it, as it didn't work out its job SmileConfused
take a look

<?php
/**
 * Mod Name: test
 * Copyright test test
 */

$plugins->add_hook("index", "bar");

function bar_info()
{
	return array(
		"name"			=> "Bar",
		"description"	=> "something.",
		"website"		=> "me",
		"author"		=> "zzz",
		"authorsite"	=> "mailto:zaher1988@blabla",
		"version"		=> "1.0",
	);
}

function bar_activate()

{
    require "./inc/adminfunctions_templates.php";
	find_replace_templatesets("index", '#\$header#', '\$header <table width="100%" cellspacing="$theme[borderwidth]">
<tr>
  <td valign="top" align="right">
<div class="bottommenu"><span class="smalltext">$logoutlink</td>
</tr>
</table>');

}


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);
	
	}
	
?>




thx Smile
$plugins->add_hook("index", "bar");
This code says to call a function named bar. I don't see the bar function in the code you posted, so it probably throws a Function Not Found type of exception.
then what should i call then !!

i'm just adding a table.

thx
All your functionality is in bar_activate and bar_deactivate so don't add any hooks.
One more small note, your XHTML is not well formed.
<td valign="top" align="right">
<div class="bottommenu"><span class="smalltext">$logoutlink
</td>
should be
<td valign="top" align="right">
<div class="bottommenu"><span class="smalltext">$logoutlink</span></div>
</td>
heloo there,

umm actually in the original file these are written

but even after removing the hook it's still not working
actually it adds it duplicate the $header the the code i'm adding in <head></head> and in the body !! .

between the double there is INCLUDE

and all theme is getting white !!

thx
guysss!:s helo
atesets("index", '#\$header#', '\$header <table width="100%" ....

When using single quotes, you don't need to slash the dollar signs. Variables are not parsed when using single quotes, only when you use double quotes. So remove the slashes from the quotes. Having said that, you do need the \$ in the first instance ("#\$header#") because it's a regular expression.
You only put one slassh in the wrong place Smile

As the others have said, at the minute you don't have a function called "bar" so you should comment out the your plugin hookfor the time being

<?php
/**
 * Mod Name: test
 * Copyright test test
 */

//$plugins->add_hook("index", "bar");

function bar_info()
{
    return array(
        "name"            => "Bar",
        "description"    => "something.",
        "website"        => "me",
        "author"        => "zzz",
        "authorsite"    => "mailto:zaher1988@blabla",
        "version"        => "1.0",
    );
}

function bar_activate()

{
    require "./inc/adminfunctions_templates.php";
    find_replace_templatesets("index", '#\$header#', '$header <table width="100%" cellspacing="$theme[borderwidth]">
<tr>
  <td valign="top" align="right">
<div class="bottommenu"><span class="smalltext">$logoutlink</td>
</tr>
</table>');

}


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);
    
    }
    
?>
hey guys !!

even that didn't work

i made it this way
function bar_activate()

{
require "./inc/adminfunctions_templates.php";
find_replace_templatesets("index", '#\$header#', '$header <table width="100%" cellspacing="$theme[borderwidth]">
<tr>
<td valign="top" align="right">
<div class="bottommenu"><span class="smalltext">$logoutlink</td>
</tr>
</table>');

}

and without a hook


but the template is always getting like that

<head>
<title>$settings[bbname]</title>
$header <table width="100%" cellspacing="$theme[borderwidth]">
<tr><td valign="top" align="right">
<div class="bottommenu"><span class="smalltext">$logoutlink <a href="$settings[bburl]/search.php"> $lang->toplinks_search</a> | <a href="$settings[bburl]/memberlist.php">$lang->toplinks_memberlist</a> | <a href="http://techex.techindo.com/rules.htm">Rules</a> | <a href="http://techex.techindo.com/chat/index.html" target="_blank">IRC Chat</a> | <a href="$settings[bburl]/misc.php?action=help">$lang->toplinks_help</a>
</td></tr>
</table>include
</head>
<body>
$header <table width="100%" cellspacing="$theme[borderwidth]">
<tr><td valign="top" align="right">
<div class="bottommenu"><span class="smalltext">$logoutlink <a href="$settings[bburl]/search.php"> $lang->toplinks_search</a> | <a href="$settings[bburl]/memberlist.php">$lang->toplinks_memberlist</a> | <a href="http://techex.techindo.com/rules.htm">Rules</a> | <a href="http://techex.techindo.com/chat/index.html" target="_blank">IRC Chat</a> | <a href="$settings[bburl]/misc.php?action=help">$lang->toplinks_help</a>
</td></tr>
</table>
....

see , there is a duplicate!!

Try not using multiple lines. Try making everyhing into one line.
function bar_activate()
{
    require "./inc/adminfunctions_templates.php";
    find_replace_templatesets("index", '#\$header#', '$header <table width="100%" cellspacing="$theme[borderwidth]"><tr><td valign="top" align="right"><div class="bottommenu"><span class="smalltext">$logoutlink</td></tr></table>');
}
Also, revert your template to the original before activating the plugin.
Pages: 1 2 3