News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

[TIP] Lazy Admin Menu

Started by Acans, September 15, 2010, 08:00:30 AM

Previous topic - Next topic

Acans

I'm quite a lazy person, there for I created a lazy admin menu for all my forums.

Everything is done in subs.php, no need to add anything to modifications.english.php because it gets everything it needs from admin.english.php. This also means it'll work with other languages packs installed. All tabs have the correct permissions, if you don't have to permission to edit boards, it won't show. If you have permissions to maintenance area and reports aren't enabled it'll still show the tab, just won't take you anywhere.

Code (Find:) Select
// Set up the menu privileges.

Code (Add Before:) Select
// Load the Lazy Admin Menu Language Strings...
loadLanguage('Admin');


Code (Find:) Select
'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,
),
),
),


Code (Replace:) Select
'admin' => array(
'title' => $txt['admin'],
'href' => $scripturl . '?action=admin',
'show' => $context['allow_admin'],
'sub_buttons' => array(
'index' => array(
'title' => $txt['admin_main'],
'show' => $context['allow_admin'],
'sub_buttons' => array(
'admincentre' => array(
'title' => $txt['admin_center'],
'href' => $scripturl . '?action=admin;area=index',
'show' => $context['allow_admin'],
),
'credits' => array(
'title' => $txt['support_credits_title'],
'href' => $scripturl . '?action=admin;area=credits',
'show' => $context['allow_admin'],
),
'news' => array(
'title' => $txt['news_title'],
'href' => $scripturl . '?action=admin;area=news',
'show' => allowedTo('edit_news', 'send_mail', 'admin_forum'),
),
'packages' => array(
'title' => $txt['package'],
'href' => $scripturl . '?action=admin;area=packages',
'show' => allowedTo('admin_forum'),
),
),
),
'config' => array(
'title' => $txt['admin_config'],
'show' => allowedTo('admin_forum'),
'sub_buttons' => array(
'corefeatures' => array(
'title' => $txt['core_settings_title'],
'href' => $scripturl . '?action=admin;area=corefeatures',
'show' => allowedTo('admin_forum'),
),
'featuresettings' => array(
'title' => $txt['modSettings_title'],
'href' => $scripturl . '?action=admin;area=featuresettings',
'show' => allowedTo('admin_forum'),
),
'security' => array(
'title' => $txt['admin_security_moderation'],
'href' => $scripturl . '?action=admin;area=securitysettings',
'show' => allowedTo('admin_forum'),
),
'languages' => array(
'title' => $txt['language_configuration'],
'href' => $scripturl . '?action=admin;area=languages',
'show' => allowedTo('admin_forum'),
),
'serversettings' => array(
'title' => $txt['admin_server_settings'],
'href' => $scripturl . '?action=admin;area=serversettings',
'show' => allowedTo('admin_forum'),
),
'current_theme' => array(
'title' => $txt['theme_current_settings'],
'href' => $scripturl . '?action=admin;area=theme;sa=settings',
'show' => allowedTo('admin_forum'),
),
'theme' => array(
'title' => $txt['theme_admin'],
'href' => $scripturl . '?action=admin;area=theme;sa=admin',
'show' => allowedTo('admin_forum'),
),
'modsettings' => array(
'title' => $txt['admin_modifications'],
'href' => $scripturl . '?action=admin;area=modsettings',
'show' => allowedTo('admin_forum'),
),
),
),
'forum' => array(
'title' => $txt['layout_controls'],
'show' => allowedTo(array('manage_boards', 'admin_forum', 'manage_smileys', 'manage_attachments', 'moderate_forum')),
'sub_buttons' => array(
'boards' => array(
'title' => $txt['admin_boards'],
'href' => $scripturl . '?action=admin;area=manageboards',
'show' => allowedTo('manage_boards'),
),
'postssettings' => array(
'title' => $txt['manageposts'],
'href' => $scripturl . '?action=admin;area=postsettings',
'show' => allowedTo(array('admin_forum', 'moderate_forum')),
),
'calendar' => array(
'title' => $txt['manage_calendar'],
'href' => $scripturl . '?action=admin;area=managecalander',
'show' => allowedTo('admin_forum'),
),
'search' => array(
'title' => $txt['manage_search'],
'href' => $scripturl . '?action=admin;area=managesearch',
'show' => allowedTo('admin_forum'),
),
'smileys' => array(
'title' => $txt['smileys_manage'],
'href' => $scripturl . '?action=admin;area=smileys',
'show' => allowedTo('manage_smileys'),
),
'attachments' => array(
'title' => $txt['attachments_avatars'],
'href' => $scripturl . '?action=admin;area=manageattachements',
'show' => allowedTo('manage_attachments'),
),
),
),
'member' => array(
'title' => $txt['admin_manage_members'],
'show' => allowedTo(array('moderate_forum', 'manage_membergroups', 'manage_bans', 'manage_permissions', 'admin_forum')),
'sub_buttons' => array(
'members' => array(
'title' => $txt['admin_users'],
'href' => $scripturl . '?action=admin;area=viewmembers',
'show' => allowedTo('moderate_forum'),
),
'membergroup' => array(
'title' => $txt['admin_groups'],
'href' => $scripturl . '?action=admin;area=membergroups',
'show' => allowedTo('manage_membergroups'),
),
'permissions' => array(
'title' => $txt['edit_permissions'],
'href' => $scripturl . '?action=admin;area=permissions',
'show' => allowedTo('manage_permissions'),
),
'registration' => array(
'title' => $txt['registration_center'],
'href' => $scripturl . '?action=admin;area=regcenter',
'show' => allowedTo(array('admin_forum', 'moderate_forum')),
),
'banlist' => array(
'title' => $txt['ban_title'],
'href' => $scripturl . '?action=admin;area=ban',
'show' => allowedTo('manage_attachments'),
),
'paidsubscriptions' => array(
'title' => $txt['paid_subscriptions'],
'href' => $scripturl . '?action=admin;area=paidsubscribe',
'show' => allowedTo('admin_forum'),
),
'search_engines' => array(
'title' => $txt['search_engines'],
'href' => $scripturl . '?action=admin;area=sengines',
'show' => allowedTo('admin_forum'),
),
),
),
'maintenance' => array(
'title' => $txt['admin_maintenance'],
'show' => allowedTo('admin_forum'),
'sub_buttons' => array(
'forum_maintenance' => array(
'title' => $txt['maintain_title'],
'href' => $scripturl . '?action=admin;area=maintain',
'show' => allowedTo('admin_forum'),
),
'schedualed' => array(
'title' => $txt['maintain_tasks'],
'href' => $scripturl . '?action=admin;area=scheduledtasks',
'show' => allowedTo('admin_forum'),
),
'mail' => array(
'title' => $txt['mailqueue_title'],
'href' => $scripturl . '?action=admin;area=mailqueue',
'show' => allowedTo('admin_forum'),
),
'reports' => array(
'title' => $txt['generate_reports'],
'href' => $scripturl . '?action=admin;area=reports',
'show' => allowedTo('admin_forum'),
),
'logs' => array(
'title' => $txt['logs'],
'href' => $scripturl . '?action=admin;area=logs',
'show' => allowedTo('admin_forum'),
),
),
),
),
),





Got Simple Portal? No Problem ;)

Code (Find:) Select
// Load the Lazy Admin Menu Language Strings...
loadLanguage('Admin');


Code (Add After:) Select
loadLanguage('SPortalAdmin');

Code (Find:) Select
'attachments' => array(
'title' => $txt['attachments_avatars'],
'href' => $scripturl . '?action=admin;area=manageattachements',
'show' => allowedTo('manage_attachments'),
),
),
),


Code (Add After:) Select
'portal' => array(
'title' => $txt['sp-adminCatTitle'],
'show' => allowedTo(array('sp_admin', 'sp_manage_settings', 'sp_manage_blocks', 'sp_manage_articles', 'sp_manage_pages', 'sp_manage_shoutbox')),
'sub_buttons' => array(
'portalconfig' => array(
'title' => $txt['sp-adminConfiguration'],
'href' => $scripturl . '?action=admin;area=portalconfig',
'show' => allowedTo(array('sp_admin', 'sp_manage_settings')),
),
'portalblocks' => array(
'title' => $txt['sp-blocksBlocks'],
'href' => $scripturl . '?action=admin;area=portalblocks',
'show' => allowedTo(array('sp_admin', 'sp_manage_blocks')),
),
'portalarticles' => array(
'title' => $txt['sp-adminColumnArticles'],
'href' => $scripturl . '?action=admin;area=portalarticles',
'show' => allowedTo(array('sp_admin', 'sp_manage_articles')),
),
'portalpages' => array(
'title' => $txt['sp_admin_pages_title'],
'href' => $scripturl . '?action=admin;area=portalpages',
'show' => allowedTo(array('sp_admin', 'sp_manage_pages')),
),
'portalshoutbox' => array(
'title' => $txt['sp_admin_shoutbox_title'],
'href' => $scripturl . '?action=admin;area=portalshoutbox',
'show' => allowedTo(array('sp_admin', 'sp_manage_shoutbox')),
),
),
),


Credits to Labradoodle-360 showing me how to load language strings.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Hj Ahmad Rasyid Hj Ismail

#1
Nice tips. Thanks. I have been looking for a way to organize my admin menu. Currently I used cms mod to manage my forum menu. May be this can be packaged as that too. And with admin custom page that have the link and button to manage all settings (like cpanel or so). Hmm... Nice, nice indeed.

EDITED: CMS Mod is no longer available from SMF Mod site/ page.

Acans

I'm no mod developer or programmer. I couldn't even get it to hide tabs like reports if the feature isn't enabled, even with IchBin™ trying to explain it to me lol.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Antechinus

Cool. I do something similar but don't take it that far as I just want the areas I use regularly. Anyone can alter it to suit themselves though. I'll move this to Tips and Tricks. :)

Acans

Exactly, it takes less than a minute to remove the tabs and category's you do not want.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Hj Ahmad Rasyid Hj Ismail

I for got to ask, is this for SMF 2.0 RCx or 1.1.x?

Antechinus

Try loading a 1.1.x menu from an array like that and see how far you get. ;)

Hj Ahmad Rasyid Hj Ismail

Quote from: Antechinus on September 16, 2010, 04:46:03 AM
Try loading a 1.1.x menu from an array like that and see how far you get. ;)
So, it's basically 2.0 RCx. He he he...  :D

Joker™

Nice tip , will make admins like me more lazy :P
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Acans

Added Simpleportal if anybody wants it.
"The Book of Arantor, 17:3-5
  And I said unto him, thy database query shalt always be sent by the messenger of $smcFunc
  And $smcFunc shall protect you against injections and evil
  And so it came to pass that mysql_query was declared deprecated and even though he says he is not
  dead yet, the time was soon to come to pass when mysql_query shall be gone and no more

Norv

Oh my kind of tip: promoting lazyness!

Thanks acans :)
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

Robert.

Very nice! :D But you stole my modification idea. :( No, just joking. :P Very good job! :D

kat

Dunno how I missed this, for so long...

It's brilliant! Ta, ѕησω!

jamiewalters68

Pretty laid out actually! I've just started emerging myself into forums. Well, I do hope I'll be able to manage my forums a little easier through this. Thanks!

Hj Ahmad Rasyid Hj Ismail

Now it is already made a mod K@. Lazy admin can be even lazier when using a packaged mod. Ha ha ha...

kat

Heh... As it happens, I think the menus should be like that, as standard. :)

Ninja ZX-10RR

As a footnote, it's this one --> http://www.simplemachines.org/community/index.php?topic=525466.0 taken from ѕησω and published by DougieFresh :D
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Hj Ahmad Rasyid Hj Ismail

Hahaha... And now it being discussed by our captain there. Interesting...

kayeshandra85

Just what I was looking for ;) I better try this. I'll just update you how it works on my end. Thanks!

Hj Ahmad Rasyid Hj Ismail

There is already a packaged mod for this. But of course you can manually do it.

kat

* K@ wonders how much of a pain it'd be, to extend this to include the "Profile" menu...

NanoSector

Quote from: ahrasis on July 26, 2014, 01:01:51 AM
There is already a packaged mod for this. But of course you can manually do it.
Why take the easy route when you can do it the hard way. ;)
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."

Steve

@ K@ ... that would be nice wouldn't it?

Lol @ NanoSector
DO NOT pm me for support!

Arantor

The answer is ugliness, it's why when I redid the profile menu in 2.1, I deliberately *didn't* do it the same way, especially since while it's not too bad in performance doing the admin menu due to a lack of people doing the admin menu thing, it's significantly more serious for the profile menu.


Arantor

Did you see what I did in 2.1 though? It's almost as good IMNSHO.

kat

Not yet. I have yummy access to young Rick's site, though. I'll have a butcher's.

Arantor

The profile menu is now at the top, along with messages and notifications.

kat

Oh, yeah! I forgot how to get to the profile, at first... :P

MUCH better. :)

Arantor

I thought so. There were people who didn't approve of the way I implemented it because loading all the profile menu every page rather than doing a call to the server to get it was obviously terrible.

kat

Well, it works. It seems to work quickly, on Rick's site, and it's infinitely better'n what's in 2.0.x.

Sooooo...



'course, being an old fart, I still prefer the old "Icons" approach. But, that's another skirmish. ;)

Arantor

I like to think I made several usability improvements in 2.1 even if they ignore consistency.

Improving the admin menu as per this tip (or mod) though is not one of them :/

Hj Ahmad Rasyid Hj Ismail

Quote from: ‽ on July 26, 2014, 10:28:13 AM
IMNSHO

Lols...

If you could maybe do the same with lazy admin menu the way you did for profile menu in 2.1? :P

I never check the code in 2.1 though have tested it. I'll wait until it is beta to do the Malay translation and going through the codes. [lazy translator mode] ;)

Arantor

You're presuming that I care enough about 2.1 to write any code for it any more.

What I did was set up a special callback in the profile to serve a dedicated template. Doing that for admin would be a mess in 2.1 simply because there's just so much more stuff and the profile popup is only a specific subset of what's in the profile since most of the things you just don't need instant access to.

jamiewalters68

I do hope I could get something great from this since I'm still a newbie. Anyway, thanks!

dougiefresh

Quote from: K@ on July 26, 2014, 04:30:55 AM
* K@ wonders how much of a pain it'd be, to extend this to include the "Profile" menu...
Better Profile Menu was written....  Only it duplicates the menu structure as SMF 2.1 Alpha 1 does it, but not the whole effect.  It's a static menu, but it's like this tip.

Steve

And it has a problem still as I posted in that mod's thread. ;)
DO NOT pm me for support!

dougiefresh

The problems have been addressed in the other thread.....

Steve

DO NOT pm me for support!

Arantor


Hj Ahmad Rasyid Hj Ismail

I just realize that this mod and the packaged mod is different in the sense that the packaged mod is listing the admin menu automatically while this mod is listing the admin menu manually. I am not sure which one is the best though but automatically should cover new menu added by mods as well, right?

Arantor

The mod does it better in pretty much every respect since it automatically covers other mods.

Hj Ahmad Rasyid Hj Ismail

What about the loading issue? Does that only applies to manual mod or the packaged mod as well?

Quote from: ‽ on July 21, 2014, 01:41:20 PM
Not a fan of loading potentially many extra files every page load for admins.

Arantor

The mod handles that by adding caching, which is A Good Thing.

Hj Ahmad Rasyid Hj Ismail

The Better Profile mod doesn't list menu automatically but manually. No caching is added as I can see. Will this cause any loading issue if compared to Lazy Admin Menu mod? (Both were originally based on this mod idea but later extended as I understand).

Arantor

No, because in the Better Profile Mod's case it doesn't dynamically load anything which is where the performance headache is. If you have a static list the cost is negligible. But the minute it's loaded on demand, you escalate the cost to cover loading all the files in question - don't forget that Admin.php (where the Admin menu is stored) is so much more than just the admin menu.

Same with profile but trying to splice the profile menu is... a joy I wouldn't even begin to recommend to anyone.

One thing I will say that is quietly annoying me about this... instead of putting in effort backporting 2.1 stuff to 2.0, I'd honestly prefer to see the time and energy being spent on getting 2.1 ready.

Hj Ahmad Rasyid Hj Ismail

Thank you for the explanation.

Agreed on the last paragraph as well.

dougiefresh

Quote from: ‽ on August 04, 2014, 06:05:26 AM
One thing I will say that is quietly annoying me about this... instead of putting in effort backporting 2.1 stuff to 2.0, I'd honestly prefer to see the time and energy being spent on getting 2.1 ready.
Like you've pointed out, it's the "joy" of modding.  Mod authors can focus on what they want to focus on.....  Although I admit, I don't understand how to "search" for issues within 2.1 to test....  And yes, I've read the How can I help? topic in the 2.1 section....

Arantor

I do understand, but at the same time it seems like energy that might better be served elsewhere. My refusal to contribute seriously to 2.1 any longer is not technical but mostly political.

As far as testing, everything needs testing. Every facet of every function needs testing. There are entire functions that have never been tested, not even by their authors. It also needs usability testing by people who, well, aren't the core team to see where there are stupid things that can be changed to improve usability.

Testing at the code level is borderline impossible, despite every attempt I made to clean up unnecessary options and reduce path complexity.

dougiefresh

Okay, okay.... Lemme finish up the last two mods that I had submitted like a year ago and never got around to fixing properly so that they would get approved....  (As well as the bug reports  :o )  and I'll look at 2.1 further...

Advertisement: