2012-03-22, 09:39 AM
dear all,
there are 2 ways for using a template in mybb. i am writing the points here. but which way is good and why? which method is not good and why it is not good like dis-advantage etc,
can any body tell or explain a bit?
on activation / installation we do somthing like this :
in activate how we place it :
and how to use/bind with hook
note : it will be called in check like if page is index or action is index etc.
mybb preferes : method 1
what i use, my style : method 2
if we use it directly in our method i.e, without template adding in db. just we are updating the variable
there are 2 ways for using a template in mybb. i am writing the points here. but which way is good and why? which method is not good and why it is not good like dis-advantage etc,
can any body tell or explain a bit?
on activation / installation we do somthing like this :
<?php
global $db, $mybb;
require MYBB_ROOT."/inc/adminfunctions_templates.php";
$template = array(
"title" => "my_template1",
"template" =>
'<table>
<tr>
<td class="tcat">
<strong>hello world</strong>
</td>
</tr>
</table>
',
"sid" => -1
);
$db->insert_query("templates", $template);
?>
in activate how we place it :
<?php
find_replace_templatesets(
"index",
'#{\$boardstats}#',
"{\$my_template1}\n{\$boardstats}"
);
?>
and how to use/bind with hook
<?php
$plugins->add_hook("pre_output_page", "hello_world");
?>
note : it will be called in check like if page is index or action is index etc.
mybb preferes : method 1
<?php
function hello_world($page)
{
eval("\$my_template1 = \"".$templates->get("index")."\";");
}
?>
what i use, my style : method 2
if we use it directly in our method i.e, without template adding in db. just we are updating the variable
<?php
function hello_world($page)
{
global $my_template1;
$my_template1 = '<table>
<tr>
<td class="tcat">
<strong>hello world</strong>
</td>
</tr>
</table>';
}
?>