integrate_admin_areas hook

Started by Suki, February 24, 2011, 09:05:31 PM

Previous topic - Next topic

Suki

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

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

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.

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

Suki

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.
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Arantor

No, just make sure $context is in the global list and set $context['sub_template'] = 'show_settings'; to reuse the standard settings template.

Suki

omg! I'm so blind!   and I was checking  ManageSettings and I saw the $context['sub_template'] = 'show_settings';  !!   many thanks!
Disclaimer: unless otherwise stated, all my posts are personal and does not represent any views or opinions held by Simple Machines.

Advertisement: