MyBB Community Forums

Full Version: How do you output a global template?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to output a custom global template. And not show the normal page, in this case i want to have a custom no permission page. And i would like to show this when a certain user group accesses a certain forum.

But instead of the default no permission template i would like to error() out a custom one.

But trying:

error($templates->get("mgcvt_no_permission"));

Doesnt work and gives a error:

Call to a member function get() on a non-object 

I know its probably really easy and i am just being extremely silly/dumb right now so Smile
Any help would be greatly appreciated Smile
Add $templates as global object, like this;
global $templates;
just before your code runs Smile
(2012-10-12, 05:50 PM)Yaldaram Wrote: [ -> ]Add $templates as global object, like this;
global $templates;
just before your code runs Smile

Ah i knew it would be something so small Smile
Thank you Smile

One more question on a custom no permission page none of the original
{$lang ... } stuff works anymore. Is there a way to fix this or not at all?
Add $lang as global object like this;
global $lang;
(2012-10-12, 05:58 PM)Yaldaram Wrote: [ -> ]Add $lang as global object like this;
global $lang;

It already is:

global $db, $mybb, $lang, $templates;
Make sure you load the language you need.
$lang->load("global");
(2012-10-12, 06:00 PM)dragonexpert Wrote: [ -> ]Make sure you load the language you need.
$lang->load("global");

Tried that but that still didn't work :/

Tried it in the activate (where the template is created) and where the function that is used for the hook.
Make sure that those language strings are already present to the file which you're loading. The language strings should be like this;
$l['some_thing'] == "Some text.";
(2012-10-12, 06:10 PM)Yaldaram Wrote: [ -> ]Make sure that those language strings are already present to the file which you're loading. The language strings should be like this;
$l['some_thing'] == "Some text.";

But i am talking about the default nopermission error langs.
I found they are contained in messages. So i tried using:

$lang->load("messages");

The thing my custom template contains things like:

{$lang->error_nopermission_guest_1}

Well its now simply showing plain text :/ so its not working like i wish it would yet.