News:

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

Main Menu

Integration hook for add tabs of modifications

Started by davidhs, August 23, 2018, 01:36:12 PM

Previous topic - Next topic

davidhs

ModifyModSettings() function (file Sources/ManageSettings.php) uses the "integrate_modify_modifications" integration hook for add sub actions.
Code (Sources/ManageSettings.php) Select
<?php

function ModifyModSettings()
{
global $context$txt;

$context['page_title'] = $txt['admin_modifications'];

$subActions = array(
'general' => 'ModifyGeneralModSettings',
// Mod authors, once again, if you have a whole section to add do it AFTER this line, and keep a comma at the end.
);

// Make it easier for mods to add new areas.
call_integration_hook('integrate_modify_modifications', array(&$subActions));

loadGeneralSettingParameters($subActions'general');

// Load up all the tabs...
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['admin_modifications'],
'help' => 'modsettings',
'description' => $txt['modification_settings_desc'],
'tabs' => array(
'general' => array(
),
),
);

// Call the right function for this sub-action.
call_helper($subActions[$_REQUEST['sa']]);
}

?>


Also is need other integration hook for add tabs of these sub actions. Now I write this in my mods:
Code (modification.xml) Select

<file name="$sourcedir/ManageSettings.php">
<operation>
<search position="before"><![CDATA[
'description' => $txt['modification_settings_desc'],
'tabs' => array(
'general' => array(
),
]]></search>
<add><![CDATA[
'my_mod' => array(
'label' => $txt['my_mod'],
'description' => $txt['my_mod_desc'],
),
]]></add>
</operation>
</file>

But something similar to this will be usefull:
Code (Sources/ManageSettings.php (function ModifyModSettings())) Select
<?php

// Load up all the tabs...
$context[$context['admin_menu_name']]['tab_data'] = array(
'title' => $txt['admin_modifications'],
'help' => 'modsettings',
'description' => $txt['modification_settings_desc'],
'tabs' => array(
'general' => array(
),
),
);

// Make it easier for mods to add new tabs.
call_integration_hook('integrate_modify_modifications_tabs', array(&$context[$context['admin_menu_name']]['tab_data']['tabs']));

?>

Suki

#1
Nah, just need to move the hook call after setting any $context vars.

Can't remember if it was already done, if not, should be, will track it later.

Edit, I vaguely remember that all the admin buttons could be modified by a single hook, can't remember if it also applies for this specific case.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Suki

Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Sesquipedalian

#3
You could already do this using the integrate_admin_areas hook, which is called from the createMenu() function in Subs-Menu.php. Here's the function that I have hooked into integrate_admin_areas in one of my mods for 2.1:

/**
 * Adds Mapper to the admin areas
 *
 * Called by:
 * 
	
	
integrate_admin_areas
 */
function mapper_admin_areas(&$menuData)
{
	
global 
$txt;

	
loadLanguage('Mapper');

	
$menuData['config']['areas']['modsettings']['subsections']['mapper'] = array($txt['mapper_admin_title']);
}


Still, it is a bit counterintuitive, so changes to make that easier are a good idea.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

Advertisement: