MyBB Community Forums

Full Version: Author Post customization (postbit)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm trying to make a plugin in order to enhance author posting bar with some information , and make a test plugin to have such behaviour working for hardcoded string, before going for the real job Smile

Nevertheless, after looking at some tutorials and browsing through the forum I cannot have my Test plugin working fine and don't manage to understand why ...

Please find below the related code, in TestPlugin_show the echo send me well filled variables, but the global variable $TestPlugin doesn't reach the template.

No doubts i'm missing the point here, so if somebody could explain me or redirect me to the appropriate ressource to handle this , it would make one human being happy over here Angel

$plugins->add_hook("showthread_start", "TestPlugin_show");

function TestPlugin_activate() {
	global $db, $lang, $mybb;
	
	$template[0] = array(
		"title"		=> 'TestPluginBar',
		"template"	=> '<td width="1">Here come the content : {$TestPlugin_data[\\\'msg\\\']} !</td>',
		"sid"		=> "-1",
		"version"	=> "1.0",
		"dateline"	=> TIME_NOW
	);
	
	foreach ($template as $row) {
		$db->insert_query("templates", $row);
	}	
	require "../inc/adminfunctions_templates.php";
	find_replace_templatesets("postbit", "#<td class=\"smalltext post_author_info\" width=\"165\">#","<!-- start: TestPlugin -->{\$TestPlugin}<!-- end: TestPlugin --><td class=\"smalltext post_author_info\" width=\"165\">");	
}

function TestPlugin_deactivate() {
	global $mybb, $db;

	$db->delete_query("templates","title='TestPluginBar'");	
	require "../inc/adminfunctions_templates.php";	
	find_replace_templatesets("postbit",'#'.preg_quote('<!-- start: TestPlugin -->{$TestPlugin}<!-- end: TestPlugin -->').'#', '',0);	
    rebuild_settings();	
}

function TestPlugin_show($post) {
	global $templates, $TestPlugin,$TestPlugin_data;
	
	$TestPlugin_data = array("msg" => 'Display me!');
	echo $TestPlugin_data['msg'];				
	eval("\$TestPlugin = \"".$templates->get("TestPluginBar")."\";");
	echo $TestPlugin;	
}