Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Global Templates 1.0
#1
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.
[Image: LogoO.png]
Reply
#2
Wow, this is great!
I've been looking for this for a LOONG time now!
Reply
#3
So this lets me put a shoutbox in all themes?

EPIC!
I'm not here often, shoot a PM or whatever if you want my discord.
Reply
#4
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.
[Image: LogoO.png]
Reply
#5
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.
Reply
#6
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.
[Image: LogoO.png]
Reply
#7
may be default in 1.6 version of myBB Toungue
Reply
#8
Nice. Actually pretty usefull. Might have a look at this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)