Customizing SMF > Graphics and Templates

Theme Dropdown Menu Issues

(1/1)

MyRealityApps:
I'm in the progress of modifying the index.template.php for my Twitter Bootstrap theme and am lost as to how to handle the dropdown menus. I have attached an image for reference and the current code I'm working. (note I removed some of the <ul></ul>'s)

My function_template_menu():


--- Code: ---function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
<div class="navbar">
<div class="navbar-inner">
<ul class="nav">';

foreach ($context['menu_buttons'] as $act => $button)
{
echo '
<li id="active', $act, '">
<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
<span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span>
</a>';
if (!empty($button['sub_buttons']))
{

foreach ($button['sub_buttons'] as $childbutton)
{
echo '
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="', $childbutton['href'], '"', isset($childbutton['target']) ? ' target="' . $childbutton['target'] . '"' : '', '>
<span', isset($childbutton['is_last']) ? ' class="last"' : '', '>', $childbutton['title'], !empty($childbutton['sub_buttons']) ? '...' : '', '</span>
</a>
</li>';
// 3rd level menus :)
if (!empty($childbutton['sub_buttons']))
{

foreach ($childbutton['sub_buttons'] as $grandchildbutton)
echo '
<li>
<a class="dropdown-toggle" data-toggle="dropdown" href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
<span', isset($grandchildbutton['is_last']) ? ' class="last"' : '', '>', $grandchildbutton['title'], '</span>
</a>
</li>';

}

echo '
</li>';
}
}
}

echo '
</ul>
</div>';
}


--- End code ---

Thanks,
Shane @ MyRealityApps

Ricky.:
Dropdown menu in SMF is array of arrays, each level is maintained by sub array and each menu item has its permission, link, display text etc in it as display element. Best way is to print_r($context['menu_buttons']) and after seeing structure, see the code for template_menu() function. It will be very easy to understand.

Navigation

[0] Message Index

Go to full version