MyBB Community Forums

Full Version: Add string text without modify template ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

Ok, I wish to add some text at the common header that is beside ths open buddy list. It is possible by modify the header_welcomeblock_member template.

But what I wish to do is min. the user who use the plugins to manual edit templates or the like.

So, I have created the following code at one page that could do that,
but, it is for that page only. Is this possibe get the same result with all pages ?

mytest.php
$somevar = '<span><a href="./test.php"><strong>MyTest</strong></a></span> |';

$search_str = '<span class="links">';
$replace_str = $search_str.$somevar;
$search_limit = 1;

eval('$welcomeblock = "'.$templates->get('header_welcomeblock_member').'";');
$welcomeblock = str_replace($search_str, $replace_str, $welcomeblock, $search_limit);
eval('$header = "'.$templates->get('header').'";');
eval('$mytest_index = "'.$templates->get('mytest').'";');

output_page($mytest_index);

Before:
Open Buddy List

After:
MyTest | Open Buddy List


Thanks,

$plugins->add_hook('global_end', 'myplugin_run');
function myplugin_run()
{
 global $welcomeblock;
 $welcomeblock = str_replace('<span class="links">', '<span class="links"><span><a href="./test.php"><strong>MyTest</strong></a></span> |', $welcomeblock, 1);
}

^ Something like that in your plugin file.
Hmm...

I have used the
$plugins->add_hook('global_end', 'somefun');

already before I asked here.

But it don't changed or added the text besides the link.



Thanks