News:

Wondering if this will always be free?  See why free is better.

Main Menu

Modifying the admin panel

Started by GameDevKev, June 17, 2015, 03:07:38 PM

Previous topic - Next topic

GameDevKev

I was searching for the code to the admin panel, specifically the navigation at the bottom
$context['quick_admin_tasks']
"Support and credits"
"Forum Maintenance"
etc.

I want to add a few more tasks. I can do it directly from Admin.template.php and that would be pretty simple, or would it be better (in terms of flexibility with upgrades, mods, etc.)  to modify the contents of $context? Where is $context defined?

Thanks for your suggestions
Forum version: SMF 2.0.10

Kindred

context is defined throughout the code and gets different values depending on what page is being loaded

So no...   you should not try to inject it into context -- you should build it into the array, like any other menu item...  (there may be a hook for it, but I'm not sure)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

GameDevKev

Forum version: SMF 2.0.10

margarett

It depends on the... Context :P

$context is defined and populated throughout SMF's Sources execution.
It should be more or less easy to have an idea by the action you're in. Eg, if your action is "admin", then start with Admin.php ;)

Just don't forget that, if you add a new action or sub-action, you probably need a new sub-template function also ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

GameDevKev

Quote from: margarett on June 17, 2015, 07:13:02 PM
Admin.php ;)

Just don't forget that, if you add a new action or sub-action, you probably need a new sub-template function also ;)

Thanks for the info guys, I'll come back and report how/what i had to do if i figure it out.
Forum version: SMF 2.0.10

GameDevKev

I couldn't find where the array is defined, so

here's what I did:

find this code in Admin.template.php
</ul>
</div>
<span class="botslice clear"><span></span></span>
</div>
</div>
<br class="clear" />';

and add the following code at the beginning of that.
<li>
<a href="http://YOURWEBSITE.com/FORUM_PATH/new_section.php"><img src="http://YOURWEBSITE.com/FORUM_PATH/Themes/default/images/admin/switch_on.png" class="home_image png_fix"></a>
<h5><a href="http://YOURWEBSITE.com/FORUM_PATH/new_section.php">New Section</a></h5>
<span class="task">New section description.</span>
</li>


Works great but will mods and updates interfere with this though or vice versa?

Forum version: SMF 2.0.10

Kindred

No no no...  Thatbis not what you should be doing.

You should be adding it to the admin array... Check admin.php or maybe subs-admin.pho. But never in the template
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

GameDevKev

Quote from: Kindred on June 18, 2015, 12:35:46 AM
No no no...  Thatbis not what you should be doing.

You should be adding it to the admin array... Check admin.php or maybe subs-admin.pho. But never in the template
ha, okay I guess I have to work on that. If anyone knows where to find code, please share.
Forum version: SMF 2.0.10

margarett

Your best bet is to look at MODs that add new sections and see how they do it ;) (although it depends heavily on where the menu link should appear)

But what you want to do (add stuff to $context['quick_admin_tasks']) comes in 2 steps...
The first one is this (Admin.php)
// The format of this array is: permission, action, title, description, icon.
$quick_admin_tasks = array(
array('', 'credits', 'support_credits_title', 'support_credits_info', 'support_and_credits.png'),
array('admin_forum', 'featuresettings', 'modSettings_title', 'modSettings_info', 'features_and_options.png'),
array('admin_forum', 'maintain', 'maintain_title', 'maintain_info', 'forum_maintenance.png'),
array('manage_permissions', 'permissions', 'edit_permissions', 'edit_permissions_info', 'permissions.png'),
array('admin_forum', 'theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id'], 'theme_admin', 'theme_admin_info', 'themes_and_layout.png'),
array('admin_forum', 'packages', 'package', 'package_info', 'packages.png'),
array('manage_smileys', 'smileys', 'smileys_manage', 'smileys_manage_info', 'smilies_and_messageicons.png'),
array('moderate_forum', 'viewmembers', 'admin_users', 'member_center_info', 'members.png'),
);

Which properly populates the array.

But the action you are trying to link MUST also exist... Actions are defined in index.php, sub-actions are defined (for the admin panel) also in Admin.php (other types of sub-actions are defined in other files)

So if you are creating a new "sub-action" under maintenance, you also need to add it to the $admin_areas array, specifically under the "maintenance" group:
'maintenance' => array(
'title' => $txt['admin_maintenance'],
'permission' => array('admin_forum'),
'areas' => array(
'maintain' => array(
'label' => $txt['maintain_title'],
'file' => 'ManageMaintenance.php',
'icon' => 'maintain.gif',
'function' => 'ManageMaintenance',
'subsections' => array(
'routine' => array($txt['maintain_sub_routine'], 'admin_forum'),
'database' => array($txt['maintain_sub_database'], 'admin_forum'),
'members' => array($txt['maintain_sub_members'], 'admin_forum'),
'topics' => array($txt['maintain_sub_topics'], 'admin_forum'),
),
),
'scheduledtasks' => array(
'label' => $txt['maintain_tasks'],
'file' => 'ManageScheduledTasks.php',
'icon' => 'scheduled.gif',
'function' => 'ManageScheduledTasks',
'subsections' => array(
'tasks' => array($txt['maintain_tasks'], 'admin_forum'),
'tasklog' => array($txt['scheduled_log'], 'admin_forum'),
),
),
'mailqueue' => array(
'label' => $txt['mailqueue_title'],
'file' => 'ManageMail.php',
'function' => 'ManageMail',
'icon' => 'mail.gif',
'subsections' => array(
'browse' => array($txt['mailqueue_browse'], 'admin_forum'),
'settings' => array($txt['mailqueue_settings'], 'admin_forum'),
),
),
'reports' => array(
'enabled' => in_array('rg', $context['admin_features']),
'label' => $txt['generate_reports'],
'file' => 'Reports.php',
'function' => 'ReportsMain',
'icon' => 'reports.gif',
),
'logs' => array(
'label' => $txt['logs'],
'function' => 'AdminLogs',
'icon' => 'logs.gif',
'subsections' => array(
'errorlog' => array($txt['errlog'], 'admin_forum', 'enabled' => !empty($modSettings['enableErrorLogging']), 'url' => $scripturl . '?action=admin;area=logs;sa=errorlog;desc'),
'adminlog' => array($txt['admin_log'], 'admin_forum', 'enabled' => in_array('ml', $context['admin_features'])),
'modlog' => array($txt['moderation_log'], 'admin_forum', 'enabled' => in_array('ml', $context['admin_features'])),
'banlog' => array($txt['ban_log'], 'manage_bans'),
'spiderlog' => array($txt['spider_logs'], 'admin_forum', 'enabled' => in_array('sp', $context['admin_features'])),
'tasklog' => array($txt['scheduled_log'], 'admin_forum'),
'pruning' => array($txt['pruning_title'], 'admin_forum'),
),
),
'repairboards' => array(
'label' => $txt['admin_repair'],
'file' => 'RepairBoards.php',
'function' => 'RepairBoards',
'select' => 'maintain',
'hidden' => true,
),
),
),


So, for more specific information, we also need more specific details for you... Are you just trying to quick link an existing page? If so, which? or are you trying to create a new page in admin?
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Advertisement: