MyBB Community Forums

Full Version: Where are the Variables Called in the Templates Stored?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If i wanted to create my own custom variable such as a points system and call it in some of the templates, what script would i have to put it in?

Yeah, it doesn't quite work like that. You don't just create a variable and put a script in it. You'd have to write a full plugin. But there's one already available called Newpoints:

http://community.mybb.com/thread-56492.html
(2011-07-30, 10:57 AM)faviouz Wrote: [ -> ]Yeah, it doesn't quite work like that. You don't just create a variable and put a script in it. You'd have to write a full plugin. But there's one already available called Newpoints:

http://community.mybb.com/thread-56492.html

I dont want to use a plugin, i was just asking where are they declared? If it doesnt work like that how does it work then lol. Plugins don't just magically work you have to declare them in there somewhere
You won't be able to make your points system then, you need a plugin. The code that is executed when you call that variable in a template is declared within the plugin.
(2011-07-30, 11:01 AM)faviouz Wrote: [ -> ]You won't be able to make your points system then, you need a plugin. The code that is executed when you call that variable in a template is declared within the plugin.

I've already made my own points system that works with mybb , so that comment is wrong. I'm just asking how to link it into the templates.
You made a functional points system with MyBB without writing a plugin? That I would like to see.

I don't quite understand what you need anyways. You need to link what to the templates? And what exactly have you already made?
I'm trying to enter a variable stored in a mysql record in the database into the templates.
There's nothing special about the variables. They're just that - variables.

Most templates live in the global scope so you can use any global variable. There might be exceptions where a template might only see a local function scope. Depends on the template and more specifically, in which scope it's being evaluated. But in general, global variables work.

Naturally your own variable has to be defined BEFORE MyBB evaluates the template. Unfortunately that's different for every template as well; for example the headerinclude template is evaluated very early, whereas main templates such as index, showthread, are evaluated at the very end of a requests lifetime (directly before its sent to the client).

Just look in any of MyBB's main files like index.php or showthread.php and search for eval() and you'll know all there is to know about templates in MyBB.