[RC3] Moving Main Menu Buttons

Started by LHW, August 31, 2010, 07:03:41 AM

Previous topic - Next topic

LHW

Can someone tell me how to move a level 1 Main Menu item to be a level 2 item under a different Main Menu item?

e.g.  How would I move Calendar under Profile, or something along those lines?

Thanks!


libra_86930

I'm having problems as well :( I've found this topic http://www.simplemachines.org/community/index.php?topic=261880.0
And I manage to create a new tab without a hitch but when I try adding a submenu using the code, I always get a blank page :o I copy pasted direct, as well as customising the links to my forum

Here's where I succeeded

'Misc' => array(
'title' => 'Misc',
'href' => 'http://shoujo-crusade.net/forum/index.php?action=forum',
'show' =>  true,
'sub_buttons' => array(



),
),


And when I copy paste directly like this


'Misc' => array(
'title' => 'Misc',
'href' => 'http://shoujo-crusade.net/forum/index.php?action=forum',
'show' =>  true,
'sub_buttons' => array(
               'view' => array(
                  'title' => $txt['calendar_menu'],
                  'href' => $scripturl . '?action=calendar',
                  'show' => allowedTo('calendar_post'),
               ),
               'post' => array(
                  'title' => $txt['calendar_post_event'],
                  'href' => $scripturl . '?action=calendar;sa=post',
                  'show' => allowedTo('calendar_post'),
              ),
            ),
         ),


Or changing the urls and titles and all, it gives me a white page :(

deansmar

Quote from: Lord High Warlock on August 31, 2010, 07:03:41 AM
Can someone tell me how to move a level 1 Main Menu item to be a level 2 item under a different Main Menu item?

e.g.  How would I move Calendar under Profile, or something along those lines?

Thanks!

all the buttons are found in the Subs.php in Sources, look for $buttons = array(

level 2 as you call it are found in the 'sub_buttons' => array(

for example i moved the Help and Search under the Forums Menu like this

'forum' => array(
'title' => empty($txt['sp-forum']) ? 'Forum' : $txt['sp-forum'],
'href' => $scripturl . ($modSettings['sp_portal_mode'] == 1 && empty($context['disable_sp']) ? '?action=forum' : ''),
'show' => in_array($modSettings['sp_portal_mode'], array(1, 3)) && empty($context['disable_sp']),
'sub_buttons' => array(
            'help' => array(
            'title' => $txt['help'],
            'href' => $scripturl . '?action=help',
            'show' => true,
        ),
'search' => array(
'title' => $txt['search'],
'href' => $scripturl . '?action=search',
'show' => $context['allow_search'],
            'is_last' => true,
                    ),
              ),
        ),

libra_86930

So I tried that code you gave. The button didn't even come out  :(

deansmar

then i would say your not using the Default theme...

LHW

Quote from: deansmar on August 31, 2010, 12:02:44 PM
Quote from: Lord High Warlock on August 31, 2010, 07:03:41 AM
Can someone tell me how to move a level 1 Main Menu item to be a level 2 item under a different Main Menu item?

e.g.  How would I move Calendar under Profile, or something along those lines?

Thanks!

all the buttons are found in the Subs.php in Sources, look for $buttons = array(

level 2 as you call it are found in the 'sub_buttons' => array(

for example i moved the Help and Search under the Forums Menu like this

'forum' => array(
'title' => empty($txt['sp-forum']) ? 'Forum' : $txt['sp-forum'],
'href' => $scripturl . ($modSettings['sp_portal_mode'] == 1 && empty($context['disable_sp']) ? '?action=forum' : ''),
'show' => in_array($modSettings['sp_portal_mode'], array(1, 3)) && empty($context['disable_sp']),
'sub_buttons' => array(
            'help' => array(
            'title' => $txt['help'],
            'href' => $scripturl . '?action=help',
            'show' => true,
        ),
'search' => array(
'title' => $txt['search'],
'href' => $scripturl . '?action=search',
'show' => $context['allow_search'],
            'is_last' => true,
                    ),
              ),
        ),


Thank you!  This seems to be exactly what I was looking for.  I'll look at it in-depth when I get home from work in a few hours. ;D


!RFAN


LHW

Yes, I looked at that the other day.  It seems to only work with Level 1 items.  e.g. While I could move Calendar to be immediately after Profile in the Main Menu (and before My Messages), I could not move it under Profile.

If it DOES allow you to move Level 1 items to Level 2, then I completely missed how to do that. :-\


!RFAN

can u attach ur subs.php here
i can try to make it possible...

LHW

If I run into problems I will.  Right now I'm at work, and won't be able to try this for several hours yet.  If I can get it to work, I'll mark this topic as solved.  :)


libra_86930

Quotethen i would say your not using the Default theme...
Yes, but the support forum there told me to ask here.

Attached my subs here. I want to put calender and Search under the Misc tabs. Anyone help?

I'm using inferno by dziner studio

LHW

Well, I managed to MOVE everything the way I wanted, but then it kicked off a bunch of template errors related to active_button.  Basically, once I moved them, it wasn't highlighting the parent button, and causing an error.

The errors looked similar to this:

Quote8: Undefined index: active_button
File: /{Server Path}/Themes/default/Errors.template.php (body_above sub template - eval?)
Line: 450

Any ideas on how to resolve these errors / make the new parent / Level 1 button the active / highlighted one?


!RFAN


libra_86930

#13
Okay I got it to work :D

//Start tab Mod


'Misc' => array(
'title' => 'Misc',
'href' => 'http://shoujo-crusade.net/forum/index.php?action=forum',
'show' =>  true,
'sub_buttons' => array(

                      'Search' => array(
                  'title' => 'Search',
                  'href' => 'http://shoujo-crusade.net/testforum/index.php?action=search',
                  'show' => true,
),


                      'Calender' => array(
                  'title' => 'Calender',
                  'href' => 'http://shoujo-crusade.net/testforum/index.php?action=calendar',
                  'show' => true,
),


                      'Shop' => array(
                  'title' => 'Shop',
                  'href' => 'http://shoujo-crusade.net/testforum/index.php?action=shop',
                  'show' => true,
),



),

),
//End tab Mod


The misc is set to my forum default so you can actually put whatever link you want there.Misc being the menu button, the search, calender and shop is obviously the submenu.

To keep adding sub menus, Just add

                      'Shop' => array(
                  'title' => 'Shop',
                  'href' => 'http://shoujo-crusade.net/testforum/index.php?action=shop',
                  'show' => true,
),


And replace the Shop part with whatever name you want then replace with your link at the href. Don't forget to put both title and link within the ' ' Or it'll give you a blank page which it gave me countless times when I forgot or missed it

Place it just after

                  'show' => true,
),


Of the previous submenu.

Hope this helps.

LHW

There's got be something else I'm missing, because all I'm doing is moving the existing buttons to be nested under other ones...I'm not trying to create a new one for them.

This is the original code from my Subs.php file:

// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
if (($menu_buttons = cache_get_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated'])
{
$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => $modSettings['sp_portal_mode'] == 3 && empty($context['disable_sp']) ? $modSettings['sp_standalone_url'] : $scripturl,
'show' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
// 'target' => '_blank',
),
'forum' => array(
'title' => empty($txt['sp-forum']) ? 'Forum' : $txt['sp-forum'],
'href' => $scripturl . ($modSettings['sp_portal_mode'] == 1 && empty($context['disable_sp']) ? '?action=forum' : ''),
'show' => in_array($modSettings['sp_portal_mode'], array(1, 3)) && empty($context['disable_sp']),
'sub_buttons' => array(
),
),
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),
'rules' => array(
'title' => !empty($modSettings['rules_tab_label']) ? $modSettings['rules_tab_label'] : $txt['rules'],
'href' => $scripturl . '?action=rules',
'show' => $user_info['is_guest'] ? !empty($modSettings['rules_enable_guest_access']) : !empty($modSettings['rules_enable_member_access']),
'sub_buttons' => array(
),
),
'search' => array(
'title' => $txt['search'],
'href' => $scripturl . '?action=search',
'show' => $context['allow_search'],
'sub_buttons' => array(
),
),
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?action=admin',
'show' => $context['allow_admin'],
'sub_buttons' => array(
'featuresettings' => array(
'title' => $txt['modSettings_title'],
'href' => $scripturl . '?action=admin;area=featuresettings',
'show' => allowedTo('admin_forum'),
),
'packages' => array(
'title' => $txt['package'],
'href' => $scripturl . '?action=admin;area=packages',
'show' => allowedTo('admin_forum'),
),
'errorlog' => array(
'title' => $txt['errlog'],
'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc',
'show' => allowedTo('admin_forum') && !empty($modSettings['enableErrorLogging']),
),
'permissions' => array(
'title' => $txt['edit_permissions'],
'href' => $scripturl . '?action=admin;area=permissions',
'show' => allowedTo('manage_permissions'),
),
'portal' => array(
'title' => $txt['sp-adminCatTitle'],
'href' => $scripturl . '?action=admin;area=portalconfig',
'show' => allowedTo(array('sp_admin', 'sp_manage_settings')),
'is_last' => true,
),
),
),
'moderate' => array(
'title' => $txt['moderate'],
'href' => $scripturl . '?action=moderate',
'show' => $context['allow_moderation_center'],
'sub_buttons' => array(
'modlog' => array(
'title' => $txt['modlog_view'],
'href' => $scripturl . '?action=moderate;area=modlog',
'show' => !empty($modSettings['modlog_enabled']),
),
'poststopics' => array(
'title' => $txt['mc_unapproved_poststopics'],
'href' => $scripturl . '?action=moderate;area=postmod;sa=posts',
'show' => $modSettings['postmod_active'],
),
'attachments' => array(
'title' => $txt['mc_unapproved_attachments'],
'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments',
'show' => $modSettings['postmod_active'],
),
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => true,
'is_last' => true,
),
),
),
'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;area=account',
'show' => allowedTo(array('profile_identity_any', 'profile_identity_own', 'manage_membergroups')),
),
'profile' => array(
'title' => $txt['forumprofile'],
'href' => $scripturl . '?action=profile;area=forumprofile',
'show' => allowedTo(array('profile_extra_any', 'profile_extra_own')),
'is_last' => true,
),
),
),
'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
'is_last' => true,
),
),
),
'notepad' => array(
'title' => $txt['notepad'],
'href' => $scripturl . '?action=notepad',
'show' => $context['allow_notepad'],
'target' => $context['browser']['is_firefox'] ? '_new' : '_blank',
'sub_buttons' => array(
'notes_popup' => array(
'title' => $txt['notes_popup'],
'href' => 'javascript:void(0)" onclick="window.open(\'' . $scripturl . '?action=notepad\',\'PopupWindow\',\'height=600,width=750,scrollbars=1,resizable=1\');return false;',
'show' => $context['allow_notepad'],
),
),
),
'calendar' => array(
'title' => $txt['calendar'],
'href' => $scripturl . '?action=calendar',
'show' => $context['allow_calendar'],
'sub_buttons' => array(
'view' => array(
'title' => $txt['calendar_menu'],
'href' => $scripturl . '?action=calendar',
'show' => allowedTo('calendar_post'),
),
'post' => array(
'title' => $txt['calendar_post_event'],
'href' => $scripturl . '?action=calendar;sa=post',
'show' => allowedTo('calendar_post'),
'is_last' => true,
),
),
),
// Google Maps Mod
'googlemap' => array(
'title' => $txt['googleMap'],
'href' => $scripturl . '?action=googlemap',
'show' => $modSettings['googleMapsEnable'] && allowedTo('googleMap_view'),
'sub_buttons' => array(
),
),
// Aeva Media changes
'media' => array(
'title' => (isset($txt['aeva_gallery']) ? $txt['aeva_gallery'] : 'Media') . (!allowedTo('aeva_access_unseen') || empty($user_info['aeva_unseen']) || $user_info['aeva_unseen'] == -1 ? '' : ' [<b>' . $user_info['aeva_unseen'] . '</b>]'),
'href' => $scripturl . '?action=media',
'show' => !empty($modSettings['aeva_enable_gallery']) && allowedTo('aeva_access'),
'sub_buttons' => !allowedTo('aeva_access_unseen') || empty($user_info['aeva_unseen']) || $user_info['aeva_unseen'] == -1 ? array() : array(
'aeva_home' => array(
'title' => $txt['aeva_home'],
'href' => $scripturl . '?action=media',
'show' => true,
),
'aeva_unseen' => array(
'title' => $txt['aeva_unseen'],
'href' => $scripturl . '?action=media;sa=unseen',
'show' => true,
'is_last' => true,
),
),
),
// End Aeva Media changes
'mlist' => array(
'title' => $txt['members_title'],
'href' => $scripturl . '?action=mlist',
'show' => $context['allow_memberlist'],
'sub_buttons' => array(
'mlist_view' => array(
'title' => $txt['mlist_menu_view'],
'href' => $scripturl . '?action=mlist',
'show' => true,
),
'mlist_search' => array(
'title' => $txt['mlist_search'],
'href' => $scripturl . '?action=mlist;sa=search',
'show' => true,
'is_last' => true,
),
),
),
'login' => array(
'title' => $txt['login'],
'href' => $scripturl . '?action=login',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
),
'register' => array(
'title' => $txt['register'],
'href' => $scripturl . '?action=register',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
'logout' => array(
'title' => $txt['logout'],
'href' => $scripturl . '?action=logout;%1$s=%2$s',
'show' => !$user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
);


Once moved to where I want them (which works, except for the entries in the Error Log), I'm left with this:

// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
if (($menu_buttons = cache_get_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated'])
{
$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => $modSettings['sp_portal_mode'] == 3 && empty($context['disable_sp']) ? $modSettings['sp_standalone_url'] : $scripturl,
'show' => true,
'sub_buttons' => array(
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),
'search' => array(
'title' => $txt['search'],
'href' => $scripturl . '?action=search',
'show' => $context['allow_search'],
'sub_buttons' => array(
),
'is_last' => true,
),
),
'is_last' => $context['right_to_left'],
// 'target' => '_blank',
),
'forum' => array(
'title' => empty($txt['sp-forum']) ? 'Forum' : $txt['sp-forum'],
'href' => $scripturl . ($modSettings['sp_portal_mode'] == 1 && empty($context['disable_sp']) ? '?action=forum' : ''),
'show' => in_array($modSettings['sp_portal_mode'], array(1, 3)) && empty($context['disable_sp']),
'sub_buttons' => array(
),
),
'rules' => array(
'title' => !empty($modSettings['rules_tab_label']) ? $modSettings['rules_tab_label'] : $txt['rules'],
'href' => $scripturl . '?action=rules',
'show' => $user_info['is_guest'] ? !empty($modSettings['rules_enable_guest_access']) : !empty($modSettings['rules_enable_member_access']),
'sub_buttons' => array(
),
),
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?action=admin',
'show' => $context['allow_admin'],
'sub_buttons' => array(
'featuresettings' => array(
'title' => $txt['modSettings_title'],
'href' => $scripturl . '?action=admin;area=featuresettings',
'show' => allowedTo('admin_forum'),
),
'packages' => array(
'title' => $txt['package'],
'href' => $scripturl . '?action=admin;area=packages',
'show' => allowedTo('admin_forum'),
),
'errorlog' => array(
'title' => $txt['errlog'],
'href' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc',
'show' => allowedTo('admin_forum') && !empty($modSettings['enableErrorLogging']),
),
'permissions' => array(
'title' => $txt['edit_permissions'],
'href' => $scripturl . '?action=admin;area=permissions',
'show' => allowedTo('manage_permissions'),
),
'portal' => array(
'title' => $txt['sp-adminCatTitle'],
'href' => $scripturl . '?action=admin;area=portalconfig',
'show' => allowedTo(array('sp_admin', 'sp_manage_settings')),
),
'moderate' => array(
'title' => $txt['moderate'],
'href' => $scripturl . '?action=moderate',
'show' => $context['allow_moderation_center'],
'sub_buttons' => array(
'modlog' => array(
'title' => $txt['modlog_view'],
'href' => $scripturl . '?action=moderate;area=modlog',
'show' => !empty($modSettings['modlog_enabled']),
),
'poststopics' => array(
'title' => $txt['mc_unapproved_poststopics'],
'href' => $scripturl . '?action=moderate;area=postmod;sa=posts',
'show' => $modSettings['postmod_active'],
),
'attachments' => array(
'title' => $txt['mc_unapproved_attachments'],
'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments',
'show' => $modSettings['postmod_active'],
),
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => true,
'is_last' => true,
),
),
'is_last' => true,
),
),
),
'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;area=account',
'show' => allowedTo(array('profile_identity_any', 'profile_identity_own', 'manage_membergroups')),
),
'profile' => array(
'title' => $txt['forumprofile'],
'href' => $scripturl . '?action=profile;area=forumprofile',
'show' => allowedTo(array('profile_extra_any', 'profile_extra_own')),
),
'notepad' => array(
'title' => $txt['notepad'],
'href' => $scripturl . '?action=notepad',
'show' => $context['allow_notepad'],
'target' => $context['browser']['is_firefox'] ? '_new' : '_blank',
'sub_buttons' => array(
'notes_popup' => array(
'title' => $txt['notes_popup'],
'href' => 'javascript:void(0)" onclick="window.open(\'' . $scripturl . '?action=notepad\',\'PopupWindow\',\'height=600,width=750,scrollbars=1,resizable=1\');return false;',
'show' => $context['allow_notepad'],
'is_last' => true,
),
'is_last' => true,
),
),
),
),
'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
'is_last' => true,
),
),
),
'calendar' => array(
'title' => $txt['calendar'],
'href' => $scripturl . '?action=calendar',
'show' => $context['allow_calendar'],
'sub_buttons' => array(
'view' => array(
'title' => $txt['calendar_menu'],
'href' => $scripturl . '?action=calendar',
'show' => allowedTo('calendar_post'),
),
'post' => array(
'title' => $txt['calendar_post_event'],
'href' => $scripturl . '?action=calendar;sa=post',
'show' => allowedTo('calendar_post'),
'is_last' => true,
),
),
),
// Aeva Media changes
'media' => array(
'title' => (isset($txt['aeva_gallery']) ? $txt['aeva_gallery'] : 'Media') . (!allowedTo('aeva_access_unseen') || empty($user_info['aeva_unseen']) || $user_info['aeva_unseen'] == -1 ? '' : ' [<b>' . $user_info['aeva_unseen'] . '</b>]'),
'href' => $scripturl . '?action=media',
'show' => !empty($modSettings['aeva_enable_gallery']) && allowedTo('aeva_access'),
'sub_buttons' => !allowedTo('aeva_access_unseen') || empty($user_info['aeva_unseen']) || $user_info['aeva_unseen'] == -1 ? array() : array(
'aeva_home' => array(
'title' => $txt['aeva_home'],
'href' => $scripturl . '?action=media',
'show' => true,
),
'aeva_unseen' => array(
'title' => $txt['aeva_unseen'],
'href' => $scripturl . '?action=media;sa=unseen',
'show' => true,
'is_last' => true,
),
),
),
// End Aeva Media changes
'mlist' => array(
'title' => $txt['members_title'],
'href' => $scripturl . '?action=mlist',
'show' => $context['allow_memberlist'],
'sub_buttons' => array(
'mlist_view' => array(
'title' => $txt['mlist_menu_view'],
'href' => $scripturl . '?action=mlist',
'show' => true,
),
// Google Maps Mod
'googlemap' => array(
'title' => $txt['googleMap'],
'href' => $scripturl . '?action=googlemap',
'show' => $modSettings['googleMapsEnable'] && allowedTo('googleMap_view'),
'sub_buttons' => array(
),
),
'mlist_search' => array(
'title' => $txt['mlist_search'],
'href' => $scripturl . '?action=mlist;sa=search',
'show' => true,
'is_last' => true,
),
),
),
'login' => array(
'title' => $txt['login'],
'href' => $scripturl . '?action=login',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
),
'register' => array(
'title' => $txt['register'],
'href' => $scripturl . '?action=register',
'show' => $user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
'logout' => array(
'title' => $txt['logout'],
'href' => $scripturl . '?action=logout;%1$s=%2$s',
'show' => !$user_info['is_guest'],
'sub_buttons' => array(
),
'is_last' => !$context['right_to_left'],
),
);


Yes, there are some mods in there, but even moving the Help & Search buttons under Home generates errors.  Any ideas as to why?


LHW

Marking this as solved, as it looks like the Dream Portal Team were kind enough to create a Mod to fix the Error Log issue when moving the Main Menu buttons: $grandchildbutton 'is_active' fix.

Thanks guys! ;D


Advertisement: