How to Add a MyBB Sidebox, No Plugins Required

How to Add a MyBB Sidebox, No Plugins Required, 4.0 out of 5 based on 4 ratings

How to Add a MyBB Sidebox, No Plugins RequiredAdd a MyBB sidebox to your forum, no MyBB plugins needed.

Sideboxes are great  for displaying various information on your forum to your members, often they’re on your portal page, but not on your index page where your main forum activity is. While there are a few MyBB plugins that can install  a MyBB sidebox for you, they can take up quite a few SQL queries and puts extra strain on your server. Here’s a small tutorial on how to manually add a basic MyBB sidebox to your forum, by coding a custom sidebox.

1. In Admin CP, go to Templates & Style > Templates > (Your Default Templates) > Index Page Templates > index.

2. Find:

{$forums}
{$boardstats}

Replace with:

<table width="100%" cellspacing="0" cellpadding="4" border="0" align="center">
<tr><td valign="top" width="160">
<table border="0" cellspacing="0" cellpadding="4" class="tborder"><tr><td class="thead"><strong>Sidebox A</strong></td></tr><tr><td class="trow1">This is a sidebox, edit me to change this text.</td></tr></table><br />
</td>
<td>&nbsp;</td>
<td valign="top">
{$forums}
{$boardstats}
</td>
</tr>
</table>

3. Change the text to what you want, “Sidebox A” is the header of the sidebox, while the rest of the text is the body of the sidebox. It should currently look like this:

How to Add a MyBB Sidebox, No Plugins Required - Complete

Again this just a basic MyBB sidebox, but it can easily be customized to your preferences. You can add more sideboxes by copying:

<table border="0" cellspacing="0" cellpadding="4" class="tborder"><tr><td class="thead"><strong>Sidebox A</strong></td></tr><tr><td class="trow1">This is a sidebox, edit me to change this text.</td></tr></table><br />

And paste just under the same code you copied, it should be like:

<table border="0" cellspacing="0" cellpadding="4" class="tborder"><tr><td class="thead"><strong>Sidebox A</strong></td></tr><tr><td class="trow1">This is a sidebox, edit me to change this text.</td></tr></table><br />
<table border="0" cellspacing="0" cellpadding="4" class="tborder"><tr><td class="thead"><strong>Sidebox B</strong></td></tr><tr><td class="trow1">This is a sidebox, edit me to change this text.</td></tr></table><br />

MyBB sidebox B has now been created:

 

How to Add a MyBB Sidebox, No Plugins Required - Sidebox BYou can adjust the width of the MyBB sidebox to fit your forum better, and generally you can be creative with them, like adding your Facebook fan page, showing your forum affiliates, displaying important threads, etc. Again it’s a basic MyBB sidebox, but you can add anything you want to them as long as you know basic HTML.

VN:F [1.9.20_1166]
Rate This post
Rating: 4.0/5 (4 votes cast)

14 thoughts on “How to Add a MyBB Sidebox, No Plugins Required

  1. Great post, thank you. In your demo is this side box displayed only in the forum index or does it show in all categories and forums?

    Also, with a box like this is is possible for it to contain, for example, some php to display gallery thumbnails or something? I’ve seen that option on something like Simple Portal (for SMF) but I’m not sure how to do it in MyBB.

    Anyway thanks for the great posts. Bookmarked.

    • The sidebox seen here is only displayed on the index page.

      Yes you can use PHP as well as Javascript, HTML, etc in the sidebox codes. The PHP code will need to replace the “This is a sidebox, edit me to change this text.” and afterward it can be executed within the browser.

      Glad you like the post. :)

  2. Hi.

    Im kind of new for this website hosting. But ive managed to come up with an ok result so far. I was just wondering how to make that sidebox align with my other stuff. Its like 2 cm above everything, and that looks wierd.

    Thanks in advance.

    -Skvist

        • Try this then, you’ll need to edit the index.php file so I suggest making a backup of it first. Edit the index.php file of your forum and find:

          $plugins->run_hooks("index_start");

          Below that add:

          // get forums user cannot view
          $unviewable = get_unviewable_forums(true);
          if($unviewable)
          {
                  $unviewwhere = " AND fid NOT IN ($unviewable)";
          }
          
                  $altbg = alt_trow();
                  $threadlist = '';
                  $query = $db->query("
                          SELECT t.*, u.username
                          FROM ".TABLE_PREFIX."threads t
                          LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
                          WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
                          ORDER BY t.lastpost DESC
                          LIMIT 0, 10"
                  );
                  while($thread = $db->fetch_array($query))
                  {
                          $lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
                          $lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
                          // Don't link to guest's profiles (they have no profile).
                          if($thread['lastposteruid'] == 0)
                          {
                                  $lastposterlink = $thread['lastposter'];
                          }
                          else
                          {
                                  $lastposterlink = build_profile_link($thread['lastposter'], $thread['lastposteruid']);
                          }
                          if(my_strlen($thread['subject']) > 25)
                          {
                                  $thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
                          }
                          $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
                          $thread['threadlink'] = get_thread_link($thread['tid']);
                          $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
                          eval("$threadlist .= "".$templates->get("portal_latestthreads_thread")."";");
                          $altbg = alt_trow();
                  }
                  if($threadlist)
                  {
                          // Show the table only if there are threads
                          eval("$latestthreads = "".$templates->get("portal_latestthreads")."";");
                  } 

          Save changes.

          On your forum’s index template, use {$latestthreads} to add latest threads above or below your sidebox.

    • Use the code like this:

      <table width="100%" cellspacing="0" cellpadding="4" border="0" align="center">
      <td>{$forums}
      {$boardstats}</td>
      <td valign="top">
      <td valign="top" width="160"><table border="0" cellspacing="0" cellpadding="4" class="tborder"><tr><td class="thead"><strong>Sidebox A</strong></td></tr><tr><td class="trow1">This is a sidebox, edit me to change this text.</td></tr></table><br />
      </td>
      </table>

  3. Hello, i use that code and work perfect! a lot of thanks!

    i have a question: where i place that code in postbit?

    i want apply that code in: index, forumdisplay and postbit.

    thanks in advance!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Powered by Sweet Captcha
Verify your real existence,
Drag the straw to the bottle
  • captcha
  • captcha
  • captcha
  • captcha