MyBB Community Forums

Full Version: {$} codes?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm curious, where does the {$} code pull the info from? Such as {$buddy_options}
I guess from a template of the same name. eg, {$header} calls the header template.
(2010-09-24, 06:43 AM)Kyuubi Wrote: [ -> ]I guess from a template.

Mostly, yes. Sometimes it can be a language string or other tid-bit of information. Best way to find out is to open up the file for the page you're looking at and searching for it. Smile
MyBB templates are actually evaluated as PHP code, so {$foo} is the PHP variable named foo. So the variables you're using in templates, are variables initialized by the PHP sourcecode of MyBB somewhere. Which variables are available is different for each template, it depends on where (which file and line) the template is evaluated in.

So for your example {$buddy_options}, there is some code in member.php which initialized the variable like so:

$buddy_options = '';

if($mybb->user['uid'] != $mybb->input['uid'] && $mybb->user['uid'] != 0)
{
       $buddy_list = explode(',', $mybb->user['buddylist']);
       if(in_array($mybb->input['uid'], $buddy_list))
       {
           $buddy_options = "<br /><a href=\"./usercp.php?action=do_editlists&amp;delete=...
...

And later on when the profile template is evaluated, it can just use this variable.

In the best case the variable will just be initialized from another template, so you can edit the other template to modify it. To modify the buddy_options as in this example, you might have to edit code or write a plugin, since stuff like the "<br />..." here is not part of a template but actually in the MyBB source code.