MyBB Community Forums

Full Version: Global Templates 1.0
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello World!

I've written a simple plugin that allows you to use your own custom templates in a theme. I present "Global Templates 1.0!"

Basically, the plugin lets you assign a "PHP name" to a template so that you can use it in other templates. Say, for instance, you create a few templates to let you have pretty windows around certain things. Under normal MyBB, you would have to copy and paste the templates everywhere. With my plugin you can just click the new "Global Templates" item under the Themes/Templates menu in the AdminCP, then add the templates with their PHP names. Then you can use them something like this:

{$winTitle}
Title
{$winContent}
Content
{$winEnd}

There are a couple of known problems right now, mainly the fact that the plugin will only use templates from the "Global Templates" set instead of template-set-specific templates where available, but this is because there's not a "global_doneLoadingTheme" plugin hook.

The plugin can be found here.
Wow, this is great!
I've been looking for this for a LOONG time now!
So this lets me put a shoutbox in all themes?

EPIC!
If only there were a hook just after global.php loaded the user's theme, but just before it handled the real global templates. then you could have theme-specific global templates to use in the theme-specific template sets.

Honestly I'm a bit surprised at this not being in MyBB by default, seeing as it's about 40 lines of code not counting the stuff needed for the hooks and plugin-specific stuff.
I don't like your approach.

Why not do something like:
<load template_name>

And then parsing, getting the template_name and fetch it.

Now you're fetching all templates and this isn't good.
It only load the templates you tell it to. That's the whole purpose of the new menu item in the Themes/Templates menu: To tell the plugin which templates to load and under which name. The way I have it keeps it consistent with the way MyBB already has it, making the learning curve far less. It also makes it so I don't have to parse each and every template that loads.
may be default in 1.6 version of myBB Toungue
Nice. Actually pretty usefull. Might have a look at this.