Back to vBulletin 4 Articles

[HOW TO - vB4] Sidebar in your own mod
by Coroner 19 Feb 2010

Do you like the sidebar ? Here I will explain how to insert it into your own mod.

1.) make sure that you have loaded forumhome.css. This is nessesary for the blocks.
2.) prepare your template(s) (modify your product).

You have to do this for all "main" templates you'd like to insert the sidebar!

search for:
Code:
</head>
and add above:
Code:
<vb:if condition="$show['sidebar']">
 <link rel="stylesheet" type="text/css" href="{vb:var vbcsspath}tagcloud.css" />
 <script type="text/javascript" src="{vb:stylevar yuipath}/animation/animation-min.js?v={vb:raw vboptions.simpleversion}"></script>
 <script type="text/javascript">
  var sidebar_align = '<vb:if condition="$vboptions['sidebarposition'] == 0">left<vb:else />right</vb:if>';
  var content_container_margin = parseInt('{vb:math {vb:stylevar forum_sidebar_width}+{vb:math {vb:stylevar padding}*2}}');
  var sidebar_width = parseInt('{vb:stylevar forum_sidebar_width}');
 </script>
 <script type="text/javascript" src="{vb:raw vboptions.bburl}/clientscript/vbulletin-sidebar.js?v={vb:raw vboptions.simpleversion}"></script>
</vb:if>
next search for:
Code:
{vb:raw header}
{vb:raw navbar}
and add below:
Code:
<vb:if condition="$show['sidebar']">
 <div id="content_container"<vb:if condition="$vboptions['sidebarposition'] == 0"> class="contentright"</vb:if>>
  <div id="content">
</vb:if>
and at least, search for:
Code:
{vb:raw footer}
and add above:
Code:
<vb:if condition="$show['sidebar']">
   </div>
  </div>
  <div id="sidebar_container"<vb:if condition="$vboptions['sidebarposition'] == 0"> class="sidebarleft"</vb:if>>
   <a id="sidebar_button_link" href="#">
    <vb:if condition="$vboptions['sidebarposition'] == 0">
    <img id="sidebar_button" src="{vb:stylevar imgdir_misc}/tab-collapsed-left.png" alt="" />
   <vb:else />
    <img id="sidebar_button" src="{vb:stylevar imgdir_misc}/tab-collapsed.png" alt="" />
   </vb:if>
  </a>
  <ul id="sidebar">
   {vb:raw sidebar}
  </ul>
 </div>
</vb:if>
3.) preparing you're php file(s). Somewhere in you file you're requireing the global.php.
Below it you can insert the following script:
Code:
// sidebar
$show['sidebar'] = false;
if ($vbulletin->options['enablesidebar'] AND !(is_browser('ie') AND !is_browser('ie', 7)))
{
	require_once (DIR . '/includes/class_block.php');
	$blockmanager = vB_BlockManager::create($vbulletin);
	$sidebar = $blockmanager->getSidebarHTML();
	if ($sidebar)
	{
		$show['sidebar'] = true;
	}
}
This is the original vBulletin Script. That means, the sidebar is always enabled, when the sidebar is enabled in the AdminCP.
If you like to change that, simply change the following line:
Code:
if ($vbulletin->options['enablesidebar'] AND !(is_browser('ie') AND !is_browser('ie', 7)))
into:
Code:
if ($sidebar_in_my_mod AND $vbulletin->options['enablesidebar'] AND !(is_browser('ie') AND !is_browser('ie', 7)))
$sidebar_in_my_mod could be a value taken from you're mod (eg. $vbulletin->options['xyz']).

Now the last step. Somewhere you have to register your "main" template, simply insert
Code:
$templater->register('sidebar', $sidebar);
We're finish now. You will see the sidebar in you own modification.

Remember: This will show all availiable blocks.
You can use this mod to set the block on page ....
Blocks on Page XXX

I hope this article is helpfull.

Coroner

Similar Mods

vB3 Sidebar vBulletin 3.0 Template Modifications

vblts.ru supports vBulletin®, 2022-2024