Advertisement:

Author Topic: Adding the standard drop-down menu to a custom theme  (Read 1736 times)

Offline Myrrdin

  • Newbie
  • *
  • Posts: 7
Adding the standard drop-down menu to a custom theme
« on: April 30, 2012, 03:52:46 PM »
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:

Code: [Select]
// 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!
« Last Edit: April 30, 2012, 04:35:01 PM by Myrrdin »

Offline NanoSector

  • Support Specialist
  • SMF Hero
  • *
  • Posts: 9,909
  • Gender: Male
    • rick2288 on Facebook
    • Yoshi2889 on GitHub
    • Test Server
Re: Adding the standard drop-down menu to a custom theme
« Reply #1 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.
My Mods / Mod Builder - A tool to easily create mods / Support team member
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Offline Myrrdin

  • Newbie
  • *
  • Posts: 7
Re: Adding the standard drop-down menu to a custom theme
« Reply #2 on: April 30, 2012, 04:37:37 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!

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,778
  • Master of BBC Abuse
Re: Adding the standard drop-down menu to a custom theme
« Reply #3 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.
Mods - Manky Old Themes - Apocalypse theme (WIP)

Going through 2.0.x in detail is like picking through something that dropped out of the rear end of a vulture. Every couple of seconds I'm like "Oooo, that's gruesome. WTF is that doing in there?"

It doesn't matter if the glass is half empty or half full. There is clearly room for more beer.

Offline Myrrdin

  • Newbie
  • *
  • Posts: 7
Re: Adding the standard drop-down menu to a custom theme
« Reply #4 on: April 30, 2012, 07:44:52 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?

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,778
  • Master of BBC Abuse
Re: Adding the standard drop-down menu to a custom theme
« Reply #5 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.
Mods - Manky Old Themes - Apocalypse theme (WIP)

Going through 2.0.x in detail is like picking through something that dropped out of the rear end of a vulture. Every couple of seconds I'm like "Oooo, that's gruesome. WTF is that doing in there?"

It doesn't matter if the glass is half empty or half full. There is clearly room for more beer.

Offline Myrrdin

  • Newbie
  • *
  • Posts: 7
Re: Adding the standard drop-down menu to a custom theme
« Reply #6 on: May 01, 2012, 07:37:38 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) :)
hxxp:www.dzinerstudio.com/index.php?PHPSESSID=e16f897155b6ca67ae83b2655e4f4dd3&topic=2586.0 [nonactive]

I am currently looking to modify this:
Code: [Select]
// 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:
Code: [Select]
// 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?
« Last Edit: May 01, 2012, 12:48:55 PM by Myrrdin »