MyBB Community Forums

Full Version: New pages made with mods and some php help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
How can I make my mods make it's own page, of course using mybb's template.

Also how can I make it so If someone enables my plugin it does what it needs to ie make a page and stuff? I cant figure out how to make it? I know this much.
global $db;
$contact_setting_1 = array(
	"sid"			=> "NULL",
	"name"			=> "contact",
	"title"			=> "Is the plugin active?",
	"description"	=> "Set amount of points that can be purchased using <b>Paypal</b>. Default : 10|20|30",
	"optionscode"	=> "text",
	"value"			=> '',
	"disporder"		=> "1",
	"gid"			=> intval($gid),
	);

Also when do I need to use a hook? Like
$plugins->add_hook('global_start','...');
You may evaluate a template and output the page using output_page($PAGE) function.
In you _install() function add the template to the database:
$db->insert_query("templates", array(
	'title' => "page_name",
	'template' => $db->escape_string("html goes here"),
	'sid' => -2,
	'version' => $mybb->version_code,
	'status' => '',
	'dateline' => TIME_NOW
));

In your hook, get the template:
eval("\$page = \"".$templates->get("page_name").\"";");
And output the template:
output_page($page);

Make sure you declare all the variables you use in the template before the eval-code.
What is I dont use _install()?
(2011-06-05, 04:53 PM)blake Wrote: [ -> ]What is I dont use _install()?

Or in your _activate() whatever you are using. Personally I insert templates, settings and database changes in the _install function and do change to existing templates in the _activate() function.

http://wiki.mybb.com/index.php/Authoring..._Functions
Also, outputting a page needs a page file (don't know if you already realise this or not). You can hook into the misc.php page to do this or you can create a separate page.php file to be distributed with the plugin.
(2011-06-05, 06:38 PM)euantor Wrote: [ -> ]Also, outputting a page needs a page file (don't know if you already realise this or not). You can hook into the misc.php page to do this or you can create a separate page.php file to be distributed with the plugin.

Not really sure what you mean?
Outputting a page can be done in any hook. All the function does is print the contents of the variable you pass on and puts in the timer. Just die() after the page is outputted.
I thought he was meaning to create a completely separate page (I'm guessing he;s doing some kind of contact form thing) and I though you had to use misc.php for that or a new file. I could be entirely wrong though Smile It's just that's how I always do it I guess haha
(2011-06-05, 06:48 PM)euantor Wrote: [ -> ]I thought he was meaning to create a completely separate page (I'm guessing he;s doing some kind of contact form thing) and I though you had to use misc.php for that or a new file. I could be entirely wrong though Smile It's just that's how I always do it I guess haha

Yeah, for a completely different page, that isn't related to any other thing on your forum, it's a good idea to use the 'misc_start' hook. For a contact page for example, indeed.
Yeah, that's what I believe he's doing judging by the variable names he's used in that small code snippet.
Pages: 1 2