MyBB Community Forums

Full Version: Using ungrouped templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello. I have added a template to my "ungrouped templates" list.

I understand that in order to use "normal" templates you have to use the format {$name}, but this doesn't work for me for ungrouped templates.

I have a ungrouped template called helloworld and I try to include it by using {$helloworld}, this however does not include the content in "helloworld".

How do I use it?
You have to eval the template first, like so:

eval("\$helloworld = \"".$templates->get("helloworld")."\";");
Hmm I thought I couldn't add PHP in templates?

Note: I'm a fairly horrible PHP coder. All I want to do is make/include a snippet of html in one of my templates, is this the right way to go?

Is there some document on this so I don't waste anyones time?
Yeah, you can't add PHP in templates. You need to eval the template in a PHP script. I'm not really sure on what page you're trying to do this, so the easiest solution would be to install this plugin:

http://mods.mybb.com/view/global-templates
Edit : not seen above response Smile
____________________________

I could not find such required documentation except the myBB wiki ; some at random topics ...
however global templates plugin may be used for embeding html code wherever you need
That's pretty much what I wanted to do. So, if I try to create my own theme / template there's no other easy way for me to include snippets of code with the template system, like a sidebar template that I can include before the {$header} on the index? I was gonna share my templates but, if you need plugins and stress I guess I'll just keep them to myself. Smile
Unless you include a plugin within the theme to add the template and eval it, then you're pretty much stuck.
@ Norodo, I feel that you can still share such snippets here (within a single thread) like custom pages of page manager
He doesn't want to use the snippets in a custom page, nor would that help at all if he was...

You need to eval the template to call it in other places. That's it.
Okay. I guess this one is solved. If I want custom snippets of HTML in a template of mine I'll either have to copy paste them or make a plugin to use snippets. Thanks for the help.