Condensed Menu

Started by Xarcell, December 26, 2012, 06:07:42 PM

Previous topic - Next topic

Xarcell

I altered the menu in an attempt to condense it. I followed the instructions via online manual. However, the sub menu items are not showing up. Here is what I have changed:

$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
),
'forum' => array(
'title' => $txt['forum'],
'href' => $scripturl . '?node=profile',
'show' => true,
'sub_buttons' => array(
'profile' => array(
'title' => $txt['profile'],
        'href' => $scripturl . '?node=profile',
        'show' => $context['allow_edit_profile'],
),
'members' => array(
'title' => $txt['members_title'],
        'href' => $scripturl . '?node=mlist',
        'show' => $context['allow_memberlist'],
),
'search' => array(
'title' => $txt['search'],
        'href' => $scripturl . '?node=search',
        'show' => $context['allow_search'],
),
'help' => array(
'title' => $txt['help'],
        'href' => $scripturl . '?node=help',
        'show' => true,
'is_last'=> true,
),
),
),
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?node=admin',
'show' => $context['allow_admin'],
'sub_buttons' => array(
'featuresettings' => array(
'title' => $txt['modSettings_title'],
'href' => $scripturl . '?node=admin;area=featuresettings',
'show' => allowedTo('admin_forum'),
),
'packages' => array(
'title' => $txt['package'],
'href' => $scripturl . '?node=admin;area=packages',
'show' => allowedTo('admin_forum'),
),
'errorlog' => array(
'title' => $txt['errlog'],
'href' => $scripturl . '?node=admin;area=logs;sa=errorlog;desc',
'show' => allowedTo('admin_forum') && !empty($modSettings['enableErrorLogging']),
),
'permissions' => array(
'title' => $txt['edit_permissions'],
'href' => $scripturl . '?node=admin;area=permissions',
'show' => allowedTo('manage_permissions'),
'is_last' => true,
),
),
),
'moderate' => array(
'title' => $txt['moderate'],
'href' => $scripturl . '?node=moderate',
'show' => $context['allow_moderation_center'],
'sub_buttons' => array(
'modlog' => array(
'title' => $txt['modlog_view'],
'href' => $scripturl . '?node=moderate;area=modlog',
'show' => !empty($modSettings['modlog_enabled']) && !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
),
'poststopics' => array(
'title' => $txt['mc_unapproved_poststopics'],
'href' => $scripturl . '?node=moderate;area=postmod;sa=posts',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'attachments' => array(
'title' => $txt['mc_unapproved_attachments'],
'href' => $scripturl . '?node=moderate;area=attachmod;sa=attachments',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?node=moderate;area=reports',
'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
'is_last' => true,
),
),
),
'calendar' => array(
'title' => $txt['calendar'],
'href' => $scripturl . '?node=calendar',
'show' => $context['allow_calendar'],
'sub_buttons' => array(
'view' => array(
'title' => $txt['calendar_menu'],
'href' => $scripturl . '?node=calendar',
'show' => allowedTo('calendar_post'),
),
'post' => array(
'title' => $txt['calendar_post_event'],
'href' => $scripturl . '?node=calendar;sa=post',
'show' => allowedTo('calendar_post'),
'is_last' => true,
),
),
),
'login' => array(
'title' => $txt['login'],
'href' => $scripturl . '?node=login',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
),
'register' => array(
'title' => $txt['register'],
'href' => $scripturl . '?node=register',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
'logout' => array(
'title' => $txt['logout'],
'href' => $scripturl . '?node=logout;%1$s=%2$s',
'show' => !$user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
);


So basically, I created a "forum" button and added profile, members, search, and help to it. I know the "href" and "show" for the "forum" is a bit odd, but I did that for the purpose of testing.

NanoSector

Can we have a live demo? Does it work with the Admin menu?
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."

Mick.

Any reason why you have this bit under the home button?

'is_last' => $context['right_to_left'],

NanoSector

Quote from: Mick G. on December 26, 2012, 07:11:00 PM
Any reason why you have this bit under the home button?

'is_last' => $context['right_to_left'],
It's standard in SMF.
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."

Mick.

Quote from: Santa2889 on December 26, 2012, 07:18:37 PM
Quote from: Mick G. on December 26, 2012, 07:11:00 PM
Any reason why you have this bit under the home button?

'is_last' => $context['right_to_left'],
It's standard in SMF.
ah ok. It's been a while since I've seen a fresh subs.php lol mine is chopped and sliced hehehe

Xarcell

Quote from: Mick G. on December 26, 2012, 07:11:00 PM
Any reason why you have this bit under the home button?

'is_last' => $context['right_to_left'],

That was there by default.

Quote from: Santa2889 on December 26, 2012, 06:24:59 PM
Can we have a live demo? Does it work with the Admin menu?

I don't have a live demo as it's being working on locally. All other buttons/tabs work fine. I even created another button  with sub-buttons to additional action items and it worked fine.

Xarcell

I figured out why. It's because the "forum" href is the same as the "home" button.

Now if I can figured out how to turn the forum into "action=forum" and make a internal homepage I'll be golden.

Antechinus

Quote from: Mick G. on December 26, 2012, 07:11:00 PM
Any reason why you have this bit under the home button?

'is_last' => $context['right_to_left'],

That's there for styling the "last" button in RTL languages. Mind you, given the use of floats these days I'm not sure it's still needed. It's probably a relic from the days when browsers didn't support CSS2 properly.

I vaguely remember something about this from when 2.0.x was in development. IE6 and IE7 needed a PHP-controlled reverse on the menu and button arrays to get the right order of display in RTL and LTR. Other browsers (IE8 and up, plus all the rest) did it just by changing the floats. 2.0.x was coded to support IE6 and IE7.

emanuele

I think there are few array_reverse in case of menus... (template_buttons_strip itself should have one)
So this should be in the todo list... O:)


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

bloc

Quote from: Antechinus on December 26, 2012, 08:07:17 PM
Quote from: Mick G. on December 26, 2012, 07:11:00 PM
Any reason why you have this bit under the home button?

'is_last' => $context['right_to_left'],

That's there for styling the "last" button in RTL languages. Mind you, given the use of floats these days I'm not sure it's still needed. It's probably a relic from the days when browsers didn't support CSS2 properly.

I vaguely remember something about this from when 2.0.x was in development. IE6 and IE7 needed a PHP-controlled reverse on the menu and button arrays to get the right order of display in RTL and LTR. Other browsers (IE8 and up, plus all the rest) did it just by changing the floats. 2.0.x was coded to support IE6 and IE7.

It was the styling foremost I think. Its a relic and should be removed. ;D

bloc

Quote from: Xarcell on December 26, 2012, 07:33:30 PM
I figured out why. It's because the "forum" href is the same as the "home" button.

Now if I can figured out how to turn the forum into "action=forum" and make a internal homepage I'll be golden.
Have a look at TP for example, on how to make new actions and delegate how you get to the forum index when there's a frontpage.

Advertisement: