News:

Want to get involved in developing SMF? Why not lend a hand on our GitHub!

Main Menu

integrate_admin_areas hook

Started by All Colours Sam, February 24, 2011, 09:05:31 PM

Previous topic - Next topic

All Colours Sam

can anyone post an example if this hook?

I was trying to follow SD code in SimpleSEF mod but he adds some code to force the button appear after the Features and Options button and has subactions, mine doesn't have sub actions and I just want it to appear at the end on the configuration menu, so far I got this:

function share_admin(&$admin_areas)
{
global $txt, $modSettings;

$admin_areas['config']['areas'] = array(

'sharethis' => array(
'label' => 'share_this_label',
'file' => 'ShareThis.php',
'function' => 'ModifyShareTopicSettings',
'icon' => 'post.gif',
),
);
}


it does show the button but breaks all the others and when I click it to go to ModifyShareTopicSettings  I get this error: Call to undefined function prepareDBSettingContext()

the ModifyShareTopicSettings is pretty much like any other function for saving settings to the database

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

Arantor

Quoteit does show the button but breaks all the others

You're overwriting $admin_areas['config']['areas'] with the new array. You need to append it thus:

$admin_areas['config']['areas']['sharethis'] = array(
'label' => 'share_this_label',
'file' => 'ShareThis.php',
'function' => 'ModifyShareTopicSettings',
'icon' => 'post.gif',
);


As for lack of prepareDBSettingContext, that generally implies your function hasn't made sure ManageServer.php is included.
Holder of controversial views, all of which my own.


Matthew K.

You'd also want to use array_slice(); to make it show after features and options.

JBlaze

Quote from: Labradoodle-360 on February 25, 2011, 01:10:05 AM
You'd also want to use array_slice(); to make it show after features and options.
There's really no need to use that. All you have to do is append it to any key on the $admin_areas array, like Arantor has posted above.
Jason Clemons
Former Team Member 2009 - 2012

All Colours Sam

thanks, its working now, I was including ManageSettings instead of ManageServer ^^  but now I get an "Unable to load the 'main' template." when I click to show the mod's settings,  what template should I call? do I have to create my own?  sorry for all the noob questions.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Arantor

No, just make sure $context is in the global list and set $context['sub_template'] = 'show_settings'; to reuse the standard settings template.
Holder of controversial views, all of which my own.


All Colours Sam

omg! I'm so blind!   and I was checking  ManageSettings and I saw the $context['sub_template'] = 'show_settings';  !!   many thanks!
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Advertisement: