News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Adding the standard drop-down menu to a custom theme

Started by Myrrdin, April 30, 2012, 03:52:46 PM

Previous topic - Next topic

Myrrdin

Hi there guys/gals! I seem to have gotten myself into a bit of a pickle. I am using the "As 2.0" theme by Fussilet and by the looks of it, it does not feature drop-down menus for the main tabs (such as administration)
.

SMF Version: 2.0.2

Now, if I check other themes; they are quite different. Subs.php is supposed to be used by the forum to create this, but the problem is that it has a very custom menu which uses javascript etc, so it has its own sections for the menus.

This is what it currently looks like:

// Start of the tab section.
echo '
<ul>';

// Show the default [home] button.
echo ($current_action=='home' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'home' ? 'current' : '' , '"><a href="', $scripturl, '">' , $txt['home'] , '</a></li>';

// Show the default [forum] button.
echo ($current_action=='forum' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'forum' ? 'current' : '' , '"><a href="', $scripturl, '?action=forum">' , $txt['forum'] , '</a></li>';

// Show the [help] button.
echo ($current_action=='help' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'help' ? 'current' : '' , '"><a href="', $scripturl, '?action=help">' , $txt['help'] , '</a></li>';


// How about the [search] button?
if ($context['allow_search'])
echo ($current_action=='search' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'search' ? 'current' : '' , '"><a href="', $scripturl, '?action=search">' , $txt['search'] , '</a></li>';

// Is the user allowed to administrate at all? ([admin])
if ($context['allow_admin'])
echo ($current_action=='admin' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'admin' ? 'current' : '' , '"><a href="', $scripturl, '?action=admin">' , $txt['admin'] , '</a></li>';

// Is the user allowed to administrate at all? ([admin])
if ($context['allow_admin'])
echo ($current_action=='admin2' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'admin2' ? 'current' : '' , '"><a href="', $scripturl, '?action=moderate">' , $txt['moderate'] , '</a></li>';

// Show the default [media] button.
echo ($current_action=='media' || $context['browser']['is_ie4']) ? '' : '' , '
<li class="' , $current_action == 'media' ? 'current' : '' , '"><a href="', $scripturl, '?action=media">' , $txt['media'] , '</a></li>';


My question is: How would I add drop-down menus for this theme?

Thanks in advance!

NanoSector

If your CSS supports it, you can.

1.1.x themes do not feature the CSS for this, so you can't unless you hack it in.

I have no idea of how this theme works or how dropdowns work, though.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Myrrdin

Quote from: Yoshi2889 on April 30, 2012, 04:14:25 PM
If your CSS supports it, you can.

1.1.x themes do not feature the CSS for this, so you can't unless you hack it in.

I have no idea of how this theme works or how dropdowns work, though.

Ah sorry, I forgot to mention that I am using SMF 2.0.2. I have added that information to the OP.

The only things related to drop-downs in the theme's index.css is related to the admin menu drop-downs when you are in the administration enter.

From what I could see, Subs.php is where the main-menu drop-downs were created and used. But since this theme uses its own main menu files with different code, it is hard for me to get it all set up.

Thank you for your input!

Antechinus

I'd throw the existing menu away and put the default one back in, then style it to suit.

Myrrdin

Quote from: Antechinus on April 30, 2012, 06:07:06 PM
I'd throw the existing menu away and put the default one back in, then style it to suit.
Although I do see this as an option, i'd like to explore my possibilities further before throwing away such an awesome menu.
Any other ideas?

Antechinus

What's awesome about it?

ETA: NVM. One of those silly wobbly blob things. You'll have to construct your own markup and css for the drop menus by using the default as a guide. The js for the wobbly blob might cause you some amusement too. Have fun.

Myrrdin

#6
Quote from: Antechinus on May 01, 2012, 02:46:16 AM
What's awesome about it?

ETA: NVM. One of those silly wobbly blob things. You'll have to construct your own markup and css for the drop menus by using the default as a guide. The js for the wobbly blob might cause you some amusement too. Have fun.
Hehe, yeah; thanks.

Question though, what would the syntax even look like for the type of buttons this theme is using?
I have tried directly copying the drop-down stuff to the theme, but it crashes when I do. I believe the drop-down code needs to be modified to suit the code I listed in the OP.
Any ideas on how to do that?

All I need is something to base my work on, I can do the rest myself.

I found this little thread that might help me a bit. (you were the one who assisted the user) :)
www.dzinerstudio.com/index.php?PHPSESSID=e16f897155b6ca67ae83b2655e4f4dd3&topic=2586.0

I am currently looking to modify this:
// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;



// Work out where we currently are.
$current_action = 'home';
if (in_array($context['current_action'], array('admin', 'ban', 'boardrecount', 'cleanperms', 'detailedversion', 'dumpdb', 'featuresettings', 'featuresettings2', 'findmember', 'maintain', 'manageattachments', 'manageboards', 'managecalendar', 'managesearch', 'membergroups', 'modlog', 'news', 'optimizetables', 'packageget', 'packages', 'permissions', 'pgdownload', 'postsettings', 'regcenter', 'repairboards', 'reports', 'serversettings', 'serversettings2', 'smileys', 'viewErrorLog', 'viewmembers')))
$current_action = 'admin';
if (in_array($context['current_action'], array('search', 'admin', 'admin2', 'calendar', 'profile', 'forum', 'media', 'mlist', 'register', 'login', 'logout', 'help', 'pm')))
$current_action = $context['current_action'];
if ($context['current_action'] == 'search2')
$current_action = 'search';

// Are we using right-to-left orientation?
if ($context['right_to_left'])
{
$first = 'last';
$last = 'first';
}
else
{
$first = 'first';
$last = 'last';
}


To incorporate this:
// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
<div class="tabs">
<ul>';
foreach ($context['menu_buttons'] as $act => $button)
{
echo '   <li><a ', $button['active_button'] ? ' class="current"' : '' , ' href="', $button['href'], '">
         <span class="menu-left"></span>
<span class="menu-right">' , $button['title'] , '</span></a>';

          //    Does this button have any subbuttons?
        if(!empty($button['sub_buttons']))
        {
            echo '
                             <div class="sub">
<ul>';
            foreach($button['sub_buttons'] as $sub_button)
                    echo '
                <li><a href="', $sub_button['href'], '">' , $sub_button['title'] , '</a></li>';
            echo '
                                 </ul>
</div>';      
         }

echo' </li>';

}

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

}


Any ideas?

Advertisement: