MyBB Community Forums

Full Version: [tutorial] adding a sidebar to mybb
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Duration: 10-20 minutes depending on your html skills.

Overview: Will add a sidebar to your index page of your default MyBB theme. If you want to add it to other themes it should be quite easily adapted.

Full Tutorial:

for the default theme of MyBB.

go to templates > modify/delete > default templates > index page templates > index.
you will see this:

Code:
<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
</head>
<body>
{$header}
{$forums}
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<thead>
<tr>
<td class="thead">
<div class="expcolimage"><img src="{$theme['imgdir']}/collapse{$collapsedimg['boardstats']}.gif" id="boardstats_img" class="expander" alt="[-]" /></div>
<div><strong>{$lang->boardstats}</strong></div>
</td>
</tr>
</thead>
<tbody style="{$collapsed['boardstats_e']}" id="boardstats_e">
{$whosonline}
{$birthdays}
{$forumstats}
</tbody>
</table>
<br />
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
    <tr>
        <td class="trow1">
            <table width="100%">
                <tr>
                    <td>
                        <img src="{$theme['imgdir']}/on.gif" alt="{$lang->new_posts}" style="vertical-align: middle; padding-bottom: 4px;" /> <span class="smalltext">{$lang->new_posts}</span><br />
                        <img src="{$theme['imgdir']}/off.gif" alt="{$lang->no_new_posts}" style="vertical-align: middle; padding-bottom: 4px;" /> <span class="smalltext">{$lang->no_new_posts}</span><br />
                        <img src="{$theme['imgdir']}/offlock.gif" alt="{$lang->forum_locked}" style="vertical-align: middle;" /> <span class="smalltext">{$lang->forum_locked}</span>
                    </td>
                    <td style="vertical-align: top; text-align: right;"><span class="smalltext">{$logoutlink}<a href="misc.php?action=markread">{$lang->markread}</a> | <a href="showteam.php">{$lang->forumteam}</a> | <a href="stats.php">{$lang->forumstats}</a></span>
                        {$loginform}
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
{$footer}
</body>
</html>

if you copy this into dreamweaver or something you can just copy put a table around the forums. like this:

Code:
<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
</head>
<body>
{$header}
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">{$forums}
      <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
        <thead>
          <tr>
            <td class="thead"><div class="expcolimage"><img src="{$theme['imgdir']}/collapse{$collapsedimg['boardstats']}.gif" id="boardstats_img" class="expander" alt="[-]" /></div>
                <div><strong>{$lang-&gt;boardstats}</strong></div></td>
          </tr>
        </thead>
        <tbody style="{$collapsed['boardstats_e']}" id="boardstats_e">
        </tbody>
        {$whosonline}
        {$birthdays}
        {$forumstats}
  <tr>
    <td></tbody></td>
  </tr>
      </table>
      <br />
      <table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
        <tr>
          <td class="trow1"><table width="100%">
              <tr>
                <td><img src="{$theme['imgdir']}/on.gif" alt="{$lang-&gt;new_posts}" style="vertical-align: middle; padding-bottom: 4px;" /> <span class="smalltext">{$lang-&gt;new_posts}</span><br />
                    <img src="{$theme['imgdir']}/off.gif" alt="{$lang-&gt;no_new_posts}" style="vertical-align: middle; padding-bottom: 4px;" /> <span class="smalltext">{$lang-&gt;no_new_posts}</span><br />
                    <img src="{$theme['imgdir']}/offlock.gif" alt="{$lang-&gt;forum_locked}" style="vertical-align: middle;" /> <span class="smalltext">{$lang-&gt;forum_locked}</span> </td>
                <td style="vertical-align: top; text-align: right;"><span class="smalltext">{$logoutlink}<a href="misc.php?action=markread">{$lang-&gt;markread}</a> | <a href="showteam.php">{$lang-&gt;forumteam}</a> | <a href="stats.php">{$lang-&gt;forumstats}</a></span> {$loginform} </td>
              </tr>
          </table></td>
        </tr>
      </table></td>
    <td width="200" valign="top">sidebar here </td>
  </tr>
</table>
</body>
</html>

this will make a space for the sidebar. if you want it in the same style as the normal forums like my forum (http://www.webberscorner.com) just add this to the sidebar.

Code:
<table border="0" cellspacing="1" cellpadding="4" width="190px">
<tr>
<td class="thead"><strong>side name</strong></td>
</tr>
<tr>
<td class="trow1">
<span class="smalltext">
<center>
stuff
</center>
</span></td>
</tr>
</table>

that would add a sidebar on the homepage. i wouldn't advise adding the sidebar on every page unless you have time a courage as it is a lot of templates to edit.

hope this helps.

dave.
Isnt this just a copy of Side boxes! templatesToungue?
zaher1988 Wrote:Isnt this just a copy of Side boxes! templatesToungue?

no, mine is simpler but less functionality Toungue
I didn't say the whole thing.. i said TEMPLATES and let me add Toungue THE IDEA Toungue Wink
zaher1988 Wrote:I didn't say the whole thing.. i said TEMPLATES and let me add Toungue THE IDEA Toungue Wink

could be the same html, dunno cause i haven't looked at yours. and sidebars were around way before mybb on forums...
Quote:and sidebars were around way before mybb on forums...
I dont understand this...
How can I make it so the sidebar is on the left instead of right?
1st.. use Side Boxes!
In index template

find
Code:
<table width="100%"  border="0">
  <tr>
    <td width="75%" valign="top">{$forums}</td>
    <td width="25%" valign="top">{$sb_welcome}{$sb_search}{$sb_stats}{$sb_latestthreads}{$sb_additional}</td>
  </tr>
</table>
replace with
Code:
<table width="100%"  border="0">
  <tr>
    <td width="25%" valign="top">{$sb_welcome}{$sb_search}{$sb_stats}{$sb_latestthreads}{$sb_additional}</td>
  <td width="75%" valign="top">{$forums}</td>
</tr>
</table>
zaher1988 Wrote:1st.. use Side Boxes!

Hehe, that's what I already had on my forums; and many thanks again!
Zaher, i used your method, very easy and nice. But is it possible to make it smaller ( the width of sidebar is too big. I put 160*600 skyscraper adsense ads and it does not look very nice, coz the sidebar is quit bigger... Can i make that sidebar 165pixels widt for example?
EDIT:
I noticed sideboxes.php is based on percents, 75% main and 25% sidebox? So I need to change all that to 85-15 or something like that? Which part do i change? Or all those 75's and 25's ? There are so many of them in that file Smile
Thanks
Pages: 1 2
Reference URL's