MyBB Community Forums

Full Version: MyBB variables List - Question.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi Peeps,

Is it possible that there is a list of variables used by MyBB, in dictionary form??

I'm creating a theme, and it's taking quite some time to find the common variables used by MyBB.

Lang variables would be of most help...

Thanks.. Wink
As a small example, create a file called test.php in your MyBB root folder and insert the following content:
<?
	define("IN_MYBB", 1);

	require_once "./global.php";

	echo '<pre>';
	var_dump($mybb);
	var_dump($lang);
	echo '</pre>';
?>

Call the file in your browser and you will see the variables' content.

BTW, you should either change the name of test.php to something that cannot be easily guessed or somehow restrict the access to this file as it may contain sensitive information.
Thanks Sp33d,

Not quite what I wanted. Sad

I was hoping there would be a library containg the full url's with the variables.

Never mind, it will just take me longer to pick my way though it. Wink
MyBB contains phpDoc commenting, which you could compile yourself using phpDoc PEAR extension. That might help you
theirs some listed here: http://wiki.mybboard.net/index.php/Autho...#Variables

its not exactly comprehensive though.
Thanks Tikitiki, and you tmhai.... Smile

I've removed the welcome text from the guest / member templates because it's not where I want to put it. Sad

However, it relies on the above templates to know who is either logged in or logged out to print the right welcome text, as in:

1/ Hi! there Guest etc,

2/ Welcome back, Lopalong. You last visited: Today, 09:58 AM.

Simply moving the variables to within a template doesn't work... So what I need is some php script written along the lines of:

if mybb user ==o echo $lang->welcome_guest

else

if mybb user -- member?? echo $lang-> welcome member

Can someone help me with that please??

PS: I've posted a pic so you can see what I mean.. Wink

[Image: th_aus.jpg]
Lopalong Wrote:Thanks Tikitiki, and you tmhai.... Smile

I've removed the welcome text from the guest / member templates because it's not where I want to put it. Sad

However, it relies on the above templates to know who is either logged in or logged out to print the right welcome text, as in:

1/ Hi! there Guest etc,

2/ Welcome back, Lopalong. You last visited: Today, 09:58 AM.

Simply moving the variables to within a template doesn't work... So what I need is some php script written along the lines of:

if mybb user ==o echo $lang->welcome_guest

else

if mybb user -- member?? echo $lang-> welcome member

Can someone help me with that please??

PS: I've posted a pic so you can see what I mean.. Wink

[Image: th_aus.jpg]

This is a slight problem - hopefully something like template conditionals could be implemented in the next release.

I think this might be a solution:
add the code from the other template into the guest and member templates and modify the added code so that it reflects the status of the user. Then in the template where you borrowed the code from, just delete it.
As long as you want to put the message above the navigation crumbs then we are still working in the part what is called header, I will assume you are using the welcome guest and welcome member for some other perposes and not willing to change in them. anyway in header template above
<navigation>
put
{$welcome_note} 
now open global.php

find
eval("\$header = \"".$templates->get("header")."\";");

above it add
if($mybb->user['uid'] > 0)
{
	$welcome_note = "Hello ".$mybb->user['username'];
}
else
{
	$welcome_note = "Hello guest";
}
Thanks,

It worked a treat.. Smile
The difficulty with creating a "dictionary" of variables is that there are a ton of them, and that they are different for each page/template. You usually cannot take one variable from one template and put it in another template.

There are a few variables that you can use for each page, and those are declared in global.php, inc/init.php. Those ones include $mybb, $lang, $header, $footer, $headerinclude (there are probably more, but those are the ones that I recall off the top of my head). The other variables only work on certain pages, or certain parts of pages.
Pages: 1 2