MyBB Community Forums

Full Version: Global template.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I have added a new template to the global template set, what i want is to just be able to edit this one template and it appears in all themes by just using{$templatename} where i would like it to appear in each theme, at the moment i have to edit the template in each theme.
How can i achieve this.
If it is a MyBB default template, I thing it is not possible by default. If it is not a default template, just delete that template from every theme template set except Global Templates.
It is only in the global templates as that is where i added it but how do i add {$templatename} to say index page and get it to show the contents of the template, like for example where you type {$boardstats} it will show the whos online bit etc.
You mean add that global template variable to all themes? A simple plugin can do it.
Oh. Alright, that will need a plugin, or a modification.

If you want it to show only in index, something like this should be enough.

$plugins->add_hook('index_end', 'somerandomfuntionname');
if(THIS_SCRIPT == 'index.php')
{
global $templatelist;
$templatelist .= ',my_template';
}
function somerandomfuntionname()
{
global $somevariable, $templates, $mybb, $theme;
eval('$somevariable = "'.$templates->get('my_template').'"');
}

Now in index put {$somevariable} to show your template.

This is an incomplete plugin. Also, if you have Template Conditionals plugin you can just use <template my_template> (works with PHP in Tempaltes too).
Instead we could write up a simple activate/deactivate template insert/remove plugin respectively. That would also not run any query as no function would be included.
(2012-06-05, 07:17 PM)crazy4cs Wrote: [ -> ]Instead we could write up a simple activate/deactivate template insert/remove plugin respectively. That would also not run any query as no function would be included.

What do you mean? To insert the desired code into the index template when activating? That will kill the purpose of a plugin, as what he wants is to be able to use {$someval} in all of his themes and edit only one global template.

You can use Template Conditionals, Plugin system, or core modifications. It all depends in where you want to show that template and if it will only be one or more.
Huh? You could manually create a global template or make the plugin create a global template, firstly. Then the next step would be to add that {$someval} to all templates (sid -1), and when if he wishes to remove it from all templates, simply deactivate the plugin. I guess this is what it should do unless I am misunderstanding what exactly he wants.
Oh, well, that sounds like a better way of doing it if you are writing a full plugin. But I think he wants it for his personal use only.
That would be easy. Adbrad, let me know if you're unable to do it, it's easy few lines, I'd write it up for you.
Pages: 1 2 3