Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: shadav on June 29, 2020, 11:57:19 AM

Title: Menu is getting out of control....how to move things in submenus?
Post by: shadav on June 29, 2020, 11:57:19 AM
So my menu is getting a bit out of control

how can move things around into more submenus

Like I don't know maybe make a menu called My Links and move the profile and pm into it

And a (not sure what to name it) menu and move the member list, buddy page, and staff list into it

and maybe a staff menu and move the moderator and admin menu to it

I'm assuming in the subs.php

everything that I try I keep getting HTTP ERROR 500
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Deaks on June 29, 2020, 12:00:01 PM
Have you looked at the Menu Editor mods?

Also you need to alter the subs.php to do this manually, if you post your subs.php we can help better.
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Sir Osis of Liver on June 29, 2020, 12:36:34 PM
Take one of the existing menus with submenus from the buttons array and substitute whatever you wany in it.  Use unique names for each array.



'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']) && !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
),
'poststopics' => array(
'title' => $txt['mc_unapproved_poststopics'],
'href' => $scripturl . '?action=moderate;area=postmod;sa=posts',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'attachments' => array(
'title' => $txt['mc_unapproved_attachments'],
'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
'is_last' => true,
),
),
),

Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: shadav on June 29, 2020, 12:39:08 PM
Quote from: Deaks on June 29, 2020, 12:00:01 PM
Have you looked at the Menu Editor mods?

Also you need to alter the subs.php to do this manually, if you post your subs.php we can help better.

nothing i've found in the mod list does this....there's mods to add menu items, rearrange menu items....but not to move them into submenus and such


so for instance in my subs.php the admin and moderator
'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'),
'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']) && !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
),
'poststopics' => array(
'title' => $txt['mc_unapproved_poststopics'],
'href' => $scripturl . '?action=moderate;area=postmod;sa=posts',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'attachments' => array(
'title' => $txt['mc_unapproved_attachments'],
'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
'is_last' => true,
),
),
),

instead of these being separate menu items, i'd like them to be one menu item and 2 submenus (with their own submenus)

these gives 500 error

'stafflinks' => array(
'title' => Staff Links,
'show' => $context['allow_moderation_center'],
'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'),
'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']) && !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
),
'poststopics' => array(
'title' => $txt['mc_unapproved_poststopics'],
'href' => $scripturl . '?action=moderate;area=postmod;sa=posts',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'attachments' => array(
'title' => $txt['mc_unapproved_attachments'],
'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
'is_last' => true,
),
),
),
),
),
),



'stafflinks' => array(
'title' => Staff Links,
'show' => $context['allow_moderation_center'],
'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'),
'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']) && !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
),
'poststopics' => array(
'title' => $txt['mc_unapproved_poststopics'],
'href' => $scripturl . '?action=moderate;area=postmod;sa=posts',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'attachments' => array(
'title' => $txt['mc_unapproved_attachments'],
'href' => $scripturl . '?action=moderate;area=attachmod;sa=attachments',
'show' => $modSettings['postmod_active'] && !empty($user_info['mod_cache']['ap']),
),
'reports' => array(
'title' => $txt['mc_reported_posts'],
'href' => $scripturl . '?action=moderate;area=reports',
'show' => !empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1',
'is_last' => true,
),
),
),
),
),

Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Sir Osis of Liver on June 29, 2020, 12:45:53 PM


'title' => Staff Links,



That's a 500 error.



'title' => 'Staff Links',


Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: shadav on June 29, 2020, 12:52:45 PM
Quote from: Sir Osis of Liver on June 29, 2020, 12:45:53 PM


'title' => Staff Links,



That's a 500 error.



'title' => 'Staff Links',



thanks for the correction, but still gives 500 error
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Sir Osis of Liver on June 29, 2020, 01:15:57 PM
It's in the 'moderate' array but can't find it, and gotta go.
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Antechinus on June 29, 2020, 06:36:31 PM
Post your Subs.php up so we can take a look at the whole kaboodle. :)
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: shadav on June 29, 2020, 06:41:37 PM
thanks
I tired but just keep getting 500 errors
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Antechinus on June 29, 2020, 07:07:35 PM
Try this one (back up the existing one, just in case).
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: shadav on June 29, 2020, 08:24:53 PM
well that half way worked.... no 500 error but also no submenu for the admin or moderator menus.....
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Antechinus on June 29, 2020, 09:12:56 PM
That looks weird. It shouldn't display the button title twice if it's only defined once in the array. Is that running the exact file I attached?
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Antechinus on June 29, 2020, 09:27:06 PM
Ok, just tried code straight from the file I attached, on my test site. Works perfectly. :D

What have you done to my nice shiny code?
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Sir Osis of Liver on June 29, 2020, 09:50:56 PM
I'm back.  Try this.  Make sure you've removed the original admin and moderate arrays.
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: shadav on June 29, 2020, 10:04:39 PM
bwahahaha Iz dids nuffin

erm it's probably either the alternative menu mod thingie or the working top level for drop down links mod

my menu's just does that  :laugh:
on a drop down, the first listing is the original menu for some strange reason....
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: shadav on June 29, 2020, 10:10:29 PM
Quote from: Sir Osis of Liver on June 29, 2020, 09:50:56 PM
I'm back.  Try this.  Make sure you've removed the original admin and moderate arrays.

unfortunately same issue, no submenus for admin/mod
and apparently the rest of my menus disappeared....
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Sir Osis of Liver on June 29, 2020, 10:14:30 PM
You'll have to remove the mods to make this work.
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Antechinus on June 29, 2020, 11:54:30 PM
Yup. Kill mods first (I noticed you weren't using their stuff for actual buttons yet). See if nice shiny code works without mods in the way (I know it does). Can proceed from there, if you still want menu mods (may require body armour and pointy sticks).
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Antechinus on July 01, 2020, 05:51:13 PM
Did you end up getting this to work? It's all just bog standard button arrays, so it should work. In fact it should be easy.

Was thinking about the mods too. Really, as long as they don't bork the standard menu buttons they shouldn't bork this custom one either. The only reason they might (or should) is if you were trying to use the same array name for two different buttons. An example would be if you left the default admin button while trying to throw in this custom one too.

'sub_buttons' => array(
'admin' => array(


You can use 'sub_buttons' => array( as often as you like, but you can only use 'admin' => array( once in the whole menu.
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Mick. on July 01, 2020, 06:06:27 PM
There are other buttons like the 'help' button and from other mods that add buttons to the menu that you can set it from show=> true to false. It alleviates the menu mumble jumble. You can still use these buttons on a side block if you wish. Help, Search, Calendar, Members

Subs.php near the bottom. 3/4 of the way
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: shadav on July 31, 2020, 02:48:12 PM
sorry just getting back to this...it didn't work on the other site, and too lazy to remove all the menu mods installed :p

but tried this on another site without any menu mods installed and got it working (a lot of trial and error on some parts)

thank you for the help :)

Quote from: Mick. on July 01, 2020, 06:06:27 PM
There are other buttons like the 'help' button and from other mods that add buttons to the menu that you can set it from show=> true to false. It alleviates the menu mumble jumble. You can still use these buttons on a side block if you wish. Help, Search, Calendar, Members

Subs.php near the bottom. 3/4 of the way
how can I set up a side block? I don't use portals, don't much care for the looks....but a block on the right side for some menu options might be nice...

now I just need to get my brain functioning to come up with "cute" menu titles to organize things into
right now I've managed to get
a staff link which has the admin and moderator links in it
a market place which has the classifieds and auctions links in it
a user menu which has the profile, pm and logout links in it

now to figure out what to do with
help, calendar, search and directory links

debating to get rid of the search link since there is a search bar in the header

er just ran into a problem
moving the logout into the user menu breaks it....if I try to log out I get
Session verification failed. Please try logging out and back in again, and then try again.
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: Antechinus on July 31, 2020, 06:41:14 PM
Quoteer just ran into a problem
moving the logout into the user menu breaks it....if I try to log out I get
Session verification failed. Please try logging out and back in again, and then try again.
Javascript problem, perhaps? The logging stuff requires javascript to work properly, so if you moved the button but haven;t called the js in the right place you'd get an error.
Title: Re: Menu is getting out of control....how to move things in submenus?
Post by: shadav on July 31, 2020, 06:48:32 PM
well i have no idea then  :P :laugh:
wouldn't the javascript still apply?
All I'm doing is moving it in the menu to a submenu
(hm ok, that may be the issue....now to figure out how to fix that)