Useful Codes for MyBB Beginners
#1
I don't know if this is already posted .
Just Letting the MyBB Beginners to know some useful codes for MyBB .

{$welcomeblock} - Include welcomeblock (user/guest view of the member bit)
{$mybbversion} - Displays softwares version
{$modcplink} - Displays link to Mod CP
{$admincplink} - Displays link to Admin CP (exclude for clients safety - reinstate it if requested)

{$mybb->settings['bbname']} - Displays boards name
{$mybb->settings['bburl']} - Displays URL to the board (use always when you have to link to something)
{$mybb->settings['homename']} - Displays homepage name (the one in the footer's menu)
{$mybb->settings['homeurl']} - Displays URL to the homepage site (the one in the footer's menu)

{$mybb->user['username']} - Displays users username
{$mybb->user['usertitle']} - Displays users usertitle
{$mybb->user['uid']} - Displays users UID (User ID)
{$mybb->user['avatar']} - Displays URL of the users avatar
{$mybb->user['lastvisit']} - Displays users last visit (date and time)
{$mybb->user['totalpms']} - Displays the total number of users messages (unread + read)
{$mybb->user['unreadpms']} - Displays number of users unread messages
{$mybb->user['postnum']} - Displays the users post count
{$mybb->user['logoutkey']} - Displays users logout key (used to logout successfully)

{$theme['imgdir']} - Displays themes image dirrectory
{$theme['imglangdir']} - Displays language specific theme image dirrectory
{$theme['tid']} - Displays the themes ID number
{$theme['logo']} - Displays themes logo
{$theme['borderwidth']} - Displays themes borderwidth number
{$theme['tablespace']} - Displays themes tablespace number

{$forum['name']} - Displays forums title
{$forum['description']} - Displays forums description
{$forum['url']} - Displays forums URL
{$forum['fid']} - Displays forums ID number
Reply
#2
Will definitely come in handy for someone in the future, probably me.

I've had occasions where I'm frantically googling trying to find what variable I need to use! Big Grin
Reply
#3
Adding to the OP, here's a little script that will display everything in $mybb and $theme. I find it super handy developing plugins so I thought I should share here. Just create a file called test.php or something in the root folder of your forum and save it with the following code:
<?php
/**
* REMEMBER TO DELETE THIS FILE ON LIVE BOARDS (OR AT LEAST COMMENT OUT DEFINE(IN_MYBB))
**/
define('IN_MYBB', 1);

require_once("./global.php");

// Just add a pound symbol (#) before either of these lines to hide the output
showMybb();
showTheme();

function showMybb()
{
	global $mybb;
	echo "<b>\$mybb object:</b>\n";
	print("<pre>".print_r($mybb, true)."</pre>");
}

function showTheme()
{
	global $theme;
	echo "<b>\$theme</b>:\n";
	print("<pre>".print_r($theme, true)."</pre>");
}

Just make sure you delete the file or comment out line 5
define('IN_MYBB'), 1)
so no evil users can see the contents of $mybb or $theme. Add a pound sign before lines 10 or 11 (showMybb(); or showTheme()Wink to hide their results from the page.
My Plugins: [1.8]|[1.6]

** Selling custom plugin that enables Bitcoin payments. PM me if interested in purchasing! **
Reply
#4
(2017-06-03, 04:08 PM)fizz Wrote: Adding to the OP, here's a little script that will display everything in $mybb and $theme. I find it super handy developing plugins so I thought I should share here. Just create a file called test.php or something in the root folder of your forum and save it with the following code:
<?php
/**
* REMEMBER TO DELETE THIS FILE ON LIVE BOARDS (OR AT LEAST COMMENT OUT DEFINE(IN_MYBB))
**/
define('IN_MYBB', 1);

require_once("./global.php");

// Just add a pound symbol (#) before either of these lines to hide the output
showMybb();
showTheme();

function showMybb()
{
	global $mybb;
	echo "<b>\$mybb object:</b>\n";
	print("<pre>".print_r($mybb, true)."</pre>");
}

function showTheme()
{
	global $theme;
	echo "<b>\$theme</b>:\n";
	print("<pre>".print_r($theme, true)."</pre>");
}

Just make sure you delete the file or comment out line 5
define('IN_MYBB'), 1)
so no evil users can see the contents of $mybb or $theme. Add a pound sign before lines 10 or 11 (showMybb(); or showTheme()Wink to hide their results from the page.

Ah , Thanks for it dude .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)