MyBB Community Forums

Full Version: Variables in templates
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How am i suppose to know which variables are available inside each template? Why theres no such thing as "Variables List" here. I assume that its "somewhere" Confused


Im also looking for a way to display lastpost fid, still no success ;/ I would like it to be available in forumbit_depth2_forum_lastpost template, how can i achieve this?

Im also using "PHP and Templates Conditions" Plugin
Greets, TB Sad
wiki is useful, though doesn't have everything.
Unfortunately for things like this you really have to just look through other plugins that do what you want, or post on the forums.

print_r() can help quite a bit too, it will print a list of all the elements within a PHP array, I've had to use it quite a bit and it's extremely helpful [ie: print_r($mybb)]
We can't exactly list every single variable that is used in MyBB, we'd just end up putting half the codebase onto the Wiki Undecided You'll be able to see what's available by looking at the code.
Mmm what about some kind of dynamic table displaying available variables in specific template(ACP)? I mean when we r using variables inside each template then theres a time(loading page) when its actually checks all variables and if they exist then value it contains is displayed to user? Why the same script cannot generate all possible variables in ACP/Templates/yourtemp/* lets say right of main editor?

also, how does plugin maker can tell&rate that variable he used will work? He don't take it from thin air or from other plugins(not all)? They somehow determine what will work ;/ So wheres the solution?
(2011-03-12, 01:01 PM)ToughBear Wrote: [ -> ]Mmm what about some kind of dynamic table displaying available variables in specific template(ACP)? I mean when we r using variables inside each template then theres a time(loading page) when its actually checks all variables and if they exist then value it contains is displayed to user? Why the same script cannot generate all possible variables in ACP/Templates/yourtemp/* lets say right of main editor?

Because people don't need that, you can just look at the code to see what's available. Plus simply seeing the name of a variable doesn't necessarily give you any indication on what is actually stored in it, does it.

(2011-03-12, 01:01 PM)ToughBear Wrote: [ -> ]also, how does plugin maker can tell&rate that variable he used will work? He don't take it from thin air or from other plugins(not all)? They somehow determine what will work ;/ So wheres the solution?

Again, plugin developers just look at the code and see what is there. Having a massive list of variables, that are not in context and in the position they are in in the code, is going to be far less helpful than just looking at the actual code yourself.