Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Antechinus on July 01, 2014, 02:31:09 PM

Title: Working top level links for drop menus
Post by: Antechinus on July 01, 2014, 02:31:09 PM
Link to Mod (https://custom.simplemachines.org/mods/index.php?mod=3884)

This mod fixes a minor annoyance in the default admin/profile/pm drop menu system, namely the lack of functioning links on the top level tabs.

Installing this mod turns the top level tabs for the admin/profile/PM areas into normal, functioning tabs, just like on the main menu.

This is just a backport of the code that is used in SMF 2.1.


This mod is licensed under the WTFPL (http://www.wtfpl.net/).

If the possibility of seeing profanity means you would prefer to not read the actual license terms, rest assured that you can do whatever you like with this mod's code.

January 09, 2015: Minor bug fix. Thanks to ♦ Ninja ZX-10RR ♦
Title: Re: Working top level links for drop menus
Post by: kat on July 01, 2014, 02:54:32 PM
Does exactly what it says, on the tin.

Nice one, Ant! :)
Title: Re: Working top level links for drop menus
Post by: Steve on July 02, 2014, 09:05:02 AM
Took me a little while to see what you meant. So when you click the top level tab, it takes you to the first choice in the dropdown, right?
Title: Re: Working top level links for drop menus
Post by: Antechinus on July 02, 2014, 09:20:22 AM
Yup. It's not a huge deal, but it's just one of those things that bugs people sometimes. People expect buttons to do something. I have no idea why it was decided to make them duds in 2.0.x, since to my way of thinking it makes no more sense than doing the same on the main menu. Hey ho.
Title: Re: Working top level links for drop menus
Post by: Burke ♞ Knight on July 02, 2014, 09:23:25 AM

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.bkm.cc.nf%2Fthankyou.gif&hash=4bd1cc1515a52d105929d91945a90e391db904da)

Title: Re: Working top level links for drop menus
Post by: Steve on July 02, 2014, 09:41:10 AM
Thanks. :D
Title: Re: Working top level links for drop menus
Post by: Ninja ZX-10RR on July 03, 2014, 10:22:56 PM
I had never noticed that slight bug but anyway thank you for the fix :D I love the license XD
Title: Re: Working top level links for drop menus
Post by: Ninja ZX-10RR on November 26, 2014, 07:26:13 PM
This mod can occasionally lead to undefined indexes or invalid arguments for foreach().
Errors such as these:
Quote
Type of error: General
http://vige.altervista.org/forum/index.php?action=profile;u=46
2: Invalid argument supplied for foreach()
File: /Sources/Subs-Menu.php
Line: 237

QuoteType of error: Undefined
http://vige.altervista.org/forum/index.php?action=profile;u=46
8: Undefined index: sections
File: /Sources/Subs-Menu.php
Line: 237

In Subs-Menu the code is foreach ($menu_context['sections'] as $section_id => $section)
{
foreach ($section['areas'] as $area_id => $area)
{
if (!isset($menu_context['sections'][$section_id]['url']))
{
$menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id;
break;
}
}
}

Should have been if (!empty($menu_context['sections']))
{
foreach ($menu_context['sections'] as $section_id => $section)
{
foreach ($section['areas'] as $area_id => $area)
{
if (!isset($menu_context['sections'][$section_id]['url']))
{
$menu_context['sections'][$section_id]['url'] = isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $area_id;
break;
}
}
}
}


Credits to a former dev for this one, he refrains from posting (and I kinda understand him, pretty much), but since you have been very kind to me in the past Ant I would like to help you out if I get the chance, and now I have one :) cheers!
Title: Re: Working top level links for drop menus
Post by: Antechinus on November 26, 2014, 09:27:14 PM
Aha. Good catch. I'll update the package tonight.
Title: Re: Working top level links for drop menus
Post by: Antechinus on January 08, 2015, 09:20:35 PM
Well that was slack. I just got around to applying the bug fix. I blame Christmas. :D

ETA: Good thing I tried this out too. It alerted me to a bug in the theme I'm working on (wasn't compatible with this mod, but is now).