News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

How to show subbuttons

Started by haschi, May 16, 2008, 06:26:42 PM

Previous topic - Next topic

haschi

Hi!

In Source / Subs.php be subbuttons. I have now created a menu, which is similar to the supersucker.

Now I would like in the second row of the sub-menus points as

  • Profile 

    • Summary
    • Account Settings
    • Forum Profile
etc.


'profile' => array(
'title' => $txt['profile'],
'href' => $scripturl . '?action=profile',
'show' => $context['allow_edit_profile'],
'sub_buttons' => array(
'summary' => array(
'title' => $txt['summary'],
'href' => $scripturl . '?action=profile',
'show' => true,
),
'account' => array(
'title' => $txt['account'],
'href' => $scripturl . '?action=profile;sa=account',
'show' => allowedTo(array('profile_identity_any', 'profile_identity_own', 'manage_membergroups')),
),
'profile' => array(
'title' => $txt['forumProfile'],
'href' => $scripturl . '?action=profile;sa=forumProfile',
'show' => allowedTo(array('profile_extra_any', 'profile_extra_own')),
),
),
),



Marco
How does it work? What do I need in the index.template.php?

haschi


H

Are you using the default theme?
-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

haschi

Yes, the basis is the default-theme.

haschi

A pity that no one helps me. Is it a secret?

Nathaniel

#5
No its not a real secret, some simple code like the example below demonstrates how this can be done.

This code will do what you want, except that its really simply formated so you will probably want to change it, but it should give you the general idea.

echo'
<table>
<tr>';
foreach($context['menu_buttons'][$context['current_action']]['sub_buttons'] as $button)
echo' <td><a href="', $button['href'], '">', $button['title'], '</a></td>';
echo '
</tr>
</table>';


This code needs to be put into the template somehow, there are a few ways you can do this. I suggest that you have a look through the template_body_above() function from the index.template.php file, you will probably want to put it somewhere there.

An example location that you could put it in, is right near the end of the template_body_above() function, after the call to the template_menu() function, You could format the table with the sub buttons so that it looks good under the main menu.

I am actually creating a mod which will allow you to configuer buttons from the admin section as opposed to hard coding in the subs.php file as you have done. This will incorperate a sub menu for each main menu element as well as sub actions for each sub menu element. I will try to have it finished after my exams sometime (~1-2wks). :)

I am thinking about making the edit for the main menu, look like the one at my site at verbtest.com, but with the normal smf menu hanging down from that, with the subbuttons in it. I can show you the edits required for that if you really want them. :)
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

Rumbaar

Not sure how you are calling the menu, and exactly how you want it to appear as normal on a 2.* forum or even what 'supersucker' means.  But you might want to take a look at the Admin.php and function AdminMain() function of defining a menu and also the Subs-Menu.php for menu syntax.
"An important reward for a job well done is a personal sense of worthwhile achievement."

[ Themes ]

haschi

#7
Ah! Thanks!!

That would invade me himself.

This is my code:


// Show the start of the tab section.
echo '
<div id="main-menu">
<ul id="menulist" class="mainpadding">';

foreach ($context['menu_buttons'] as $act => $button)
{
echo '
<li>
<a ', $button['active_button'] ? 'class="active"' : '',' href="', $button['href'], '">', $button['title'], '</a>';

if (!empty($button['sub_buttons']))
{
echo '
<ul>';

foreach ($button['sub_buttons'] as $act => $sub)
{
echo '
<li>
<a href="', $sub['href'], '">' , $sub['title'], '</a>
</li>';
}
echo '
</ul>';
}
echo '
</li>';
}
// The end of tab section.
echo '
</ul>';
echo ' <script type="text/javascript" language="JavaScript"><!-- // --><![CDATA[
menuHandle = new smfMenu("menulist");
// ]]></script>
</div>



Advertisement: