Customizing SMF > Graphics and Templates
SMF2.0 - modifying theme to add menu-bar buttons
splashmonkey:
Hi
I run a forum on SMF1.1.10 and have a few extra buttons in my menu-bar (see attached) which link to external pages: these are configured in index.template.php and work fine. When running a test of the upgrade to SMF2.0 I noticed that the old them is rather badly mangled (which isn't a problem - this kind of thing I expect from a major version release!) so I was looking to add them back in, and I believe I need to add them into Boardindex.template.php however I'm a little stuck as to how to go about this - what format should these links take, and where in the file should they reside?
I hope this all makes sense - if not please feel free to ask away and I'll be more than happy to give any answers I can.
Thanks in advance for any assistance you can provide!
Eren Yaşarkurt:
Its index.template.php and the part you need to change is:
--- Code: ---// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;
echo '
<div id="main_menu">
<ul class="dropmenu" id="menu_nav">';
foreach ($context['menu_buttons'] as $act => $button)
{
echo '
<li id="button_', $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']))
{
echo '
<ul>';
foreach ($button['sub_buttons'] as $childbutton)
{
echo '
<li>
<a href="', $childbutton['href'], '"', isset($childbutton['target']) ? ' target="' . $childbutton['target'] . '"' : '', '>
<span', isset($childbutton['is_last']) ? ' class="last"' : '', '>', $childbutton['title'], !empty($childbutton['sub_buttons']) ? '...' : '', '</span>
</a>';
// 3rd level menus :)
if (!empty($childbutton['sub_buttons']))
{
echo '
<ul>';
foreach ($childbutton['sub_buttons'] as $grandchildbutton)
echo '
<li>
<a', $grandchildbutton['active_button'] ? ' class="active"' : '', ' href="', $grandchildbutton['href'], '"', isset($grandchildbutton['target']) ? ' target="' . $grandchildbutton['target'] . '"' : '', '>
<span', isset($grandchildbutton['is_last']) ? ' class="last"' : '', '>', $grandchildbutton['title'], '</span>
</a>
</li>';
echo '
</ul>';
}
echo '
</li>';
}
echo '
</ul>';
}
echo '
</li>';
}
echo '
</ul>
</div>';
}
--- End code ---
splashmonkey:
Many thanks forsakenlad - and now for the really pathetic part... How do I actually code the links/buttons? I'm somewhere below a slug in terms of PHP skills I'm afraid :(
EDIT - ok, scratch that - while searching around I found http://www.simplemachines.org/community/index.php?topic=261880.0 which would seem to do exactly as I need, so I've added a couple of buttons in the format
--- Code: ---),
),
'ventrilo' => array(
'title' => $txt['ventrilo'],
'href' => 'http://www.seedsofglory.net/ventrilo.htm',
'show' => true,
'sub_buttons' => array(
),
--- End code ---
however I'm now getting
--- Quote ---Parse error: syntax error, unexpected ';', expecting ')' in E:\xampp\xampp\htdocs\sog\Sources\Subs.php on line 4010
--- End quote ---
Line 4010 being the end of the section (ie immediately before "// Now we put the buttons in the context so the theme can use them."). Any ideas?
Eren Yaşarkurt:
Navigate to the end of the function, you'll see something like this:
--- Code: --- echo '
</ul>
</div>';
--- End code ---
Replace it like this adding the links you want:
--- Code: --- echo '
<li><a class="firstlevel" href="#"><span class="firstlevel">Menu</span></a></li>
<li><a class="firstlevel" href="#"><span class="firstlevel">Menu2</span></a></li>
</ul>
</div>';
--- End code ---
splashmonkey:
gah, my last update error has been fixed by correcting my shoddy typing... I now have the buttons available, I just don't have any text on them. I'll re-read that howto and see if I can get it working :)
Thanks for your help thus far forsakenlad!
Navigation
[0] Message Index
[#] Next page
Go to full version