Advertisement:

Author Topic: Integration hook for add tabs of modifications  (Read 5377 times)

Offline davidhs

  • Sophist Member
  • *****
  • Posts: 1,107
  • Gender: Male
Integration hook for add tabs of modifications
« 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']));

?>

Offline Suki

  • Carthago delenda est
  • On Hiatus
  • SMF Super Hero
  • *
  • Posts: 15,731
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Re: Integration hook for add tabs of modifications
« Reply #1 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.
« Last Edit: August 23, 2018, 02:34:35 PM by Suki »
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Making tough decisions, so you don't have to.

Offline Suki

  • Carthago delenda est
  • On Hiatus
  • SMF Super Hero
  • *
  • Posts: 15,731
  • Oh, wouldn't it be great if I *was* crazy?
    • MissAllSunday on GitHub
    • SMF mods
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Making tough decisions, so you don't have to.

Offline Sesquipedalian

  • The Mad Doctor
  • Developer
  • Sophist Member
  • *
  • Posts: 1,129
  • Gender: Male
  • It works! ... in theory.
    • Sesquipedalian on GitHub
Re: Integration hook for add tabs of modifications
« Reply #3 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.
« Last Edit: August 28, 2018, 01:25:27 AM by Sesquipedalian »
I promise you nothing.

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