Simple Machines Community Forum

SMF Development => Feature Requests => Applied or Declined Requests => Topic started by: davidhs on August 23, 2018, 01:36:12 PM

Title: Integration hook for add tabs of modifications
Post by: davidhs on August 23, 2018, 01:36:12 PM
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']));

?>
Title: Re: Integration hook for add tabs of modifications
Post by: Suki on August 23, 2018, 01:59:25 PM
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.
Title: Re: Integration hook for add tabs of modifications
Post by: Suki on August 25, 2018, 12:36:10 PM
Tracked. https://github.com/SimpleMachines/SMF2.1/issues/4960
Title: Re: Integration hook for add tabs of modifications
Post by: Sesquipedalian on August 28, 2018, 12:15:15 AM
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.