News:

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

Main Menu

Integrate hookup functions

Started by CapadY, June 03, 2011, 12:11:51 PM

Previous topic - Next topic

CapadY

When I am well informed since RC3 hookup functions are introduced.

When I look at the information that I can find about it till now it should be quit easy to add some functions to SMF but it isn't that clear how to use it.

At the moment I've add something shown in the forum but I want it to enable/disble in the administration to be shown.
Is it possible to use an hookup to make this extra option in the Admin part ? (Boardoption)

And if, can sombody explain how ?


Please, don't PM me for support unless invited.
If you don't understand this, you will be blacklisted.

All Colours Sam

Hi, yes there is an admin hook, I usually used like this:


// The admin hook
function ModAdmin(&$admin_areas){

global $txt;

$admin_areas['config']['areas']['mymod'] = array(
'label' => $txt['mod_description'],
'file' => 'MyFile.php',
'function' => 'ModifyModSettings',
'icon' => 'posts.gif',
);

}



on this particular case it will add a new button on the configuration menu in the admin panel, after that you will have to build your  ModifyModSettings();  function  inside your  MyMod.php  file  with something like this:


// The settings hook
function ModifyModSettings($return_config = false){

global $txt, $scripturl, $context, $sourcedir;

require_once($sourcedir . '/ManageServer.php');  // Important!

$config_vars = array(
// My arrays ie: array('check', 'something' ),
);

if ($return_config)
return $config_vars;

$context['post_url'] = $scripturl . '?action=admin;area=mymod;save';  // the url
$context['settings_title'] = $txt['somthing_admin_panel']; // the name
$context['page_title'] = $txt['somthing'];  // the page title
$context['sub_template'] = 'show_settings';

// Saving?
if (isset($_GET['save'])){

checkSession();
saveDBSettings($config_vars);
writeLog();
redirectexit('action=admin;area=mymod');
}

prepareDBSettingContext($config_vars);

}
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

live627

integrate_admin_areas modifies the admin menu
integrate_admin_include calls a file to include only for the admin panel

I should look this up to verify this is correct :P

EDIT verified. My memory hasn't failed me yet! :P

Advertisement: