MyBB Community Forums

Full Version: I don't get the {$var} references
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,

I'm just starting with myBB and I need to make some custom templates to add functionality to my board.

I simply can't find any documentation about all the {$var} references in the templates. I'm guessing this is a reference to global objects or something, but I can't find info on it.

What I want to do is query the DB for user groups and populate a select box with the returned values. The code where it needs to fit is the {$modoptions} variable:
</tr>
{$modoptions}
{$subscriptionmethod}
{$captcha}
</table>

How can I see where {$modoptions} is taken from? There's no reference other than this variable name.

I'm at total loss here Sad
(2011-10-31, 12:37 AM)ReinierK Wrote: [ -> ]Hi there,
...
I'm at total loss here Sad

Hi, welcome to MyBB Smile

#
((If no one comes along with more detailed answer))

You could easily search the entire 'MyBB' directory for the term $modoptions, using either Command line search (if you have a VPS/ or server), a Windows utility, or Dreamweaver's search function (for example)

This should give you a complete answer in < 5 minutes.


Note: Some of the template vars are global, and many others only work in certain templates, this is why there is no full documentation yet.
Yes that shows where it's defined and used, but I'm looking for documentation of how the variables are used in templates.

For example, I need to access the user's group title. I made that bold, because I can access the group ID with {$mybb->user['usergroup']}, but how can I look up the actual group name?

There's no title stored in the user object, only the index, so how would I get the actual group title in a template?

The system is a little confusing and the documentation doesn't go much further than the basics.

Cheers,
Reinier
You can try to use $groupscache. It is an array where usergroups information stored in cache. Hopefully with that, you don't need to query your db any more.
take a look at the Cache Manager in the ACP > Tools and Maintenance section. This will display all the available cache objects. Then Click on the one you want to use to see its content/structure.
Yeah thanks, but a template won't let you loop through an array, so I'm forced to edit the actual PHP file anyway.

Now that we're on that topic: I managed to create a selectbox in the modoptions section of a new thread, but where does the actual database write take place?

I need to write the selected options to the database, but I can't seem to find where the actual new thread is written to the database.

EDIT: I found it in post.php

In all honesty, the code could use some cleanup ;-)
(2011-10-31, 11:07 PM)ReinierK Wrote: [ -> ]Yeah thanks, but a template won't let you loop through an array, so I'm forced to edit the actual PHP file anyway.

Now that we're on that topic: I managed to create a selectbox in the modoptions section of a new thread, but where does the actual database write take place?

I need to write the selected options to the database, but I can't seem to find where the actual new thread is written to the database.

EDIT: I found it in post.php

In all honesty, the code could use some cleanup ;-)

sounds like you really need to learn the plugin system. if you are wanting to do something to a post before it is saved, then there are plugin hooks to use that will let you modify the post/thread data before it is written.

also, the plugin system will let you add your usergroup dropdown before the new thread/post is displayed

you should not really have to make any core file edits for 99.999999% of things anyone would want to do