Uutiset:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu
Advertisement:

How to add a button in the ACP (subgroup "members")

Aloittaja Draffi, syyskuu 01, 2013, 02:13:44 IP

« edellinen - seuraava »

Draffi

Hello!

What file i need to change that i can add a menu-button in the ACP => Submenu "members" ?

Please, can give somebody me a codeexample?

Thank you

D.

Arantor

What version of SMF?

Do you actually have something to run when you click on it or do you want help with that too?
Holder of controversial views, all of which my own.


Draffi

Thank you for the fast reply...

:-[ sure...i forget this: SMF 2.0.4

i have a php-script, that i want to open "soccer.php" (sources directory) and a template in the themes directory "soccer.template.php".

I add
'soccer' => array('soccer.php', 'soccer'),
in the index.php, too

IchBin™

You can do it a couple of ways.

Option 1: You can manually edit the menu array in Sources/Subs.php (easiest)
http://wiki.simplemachines.org/smf/Buttons_-_How_do_I_add_buttons_to_SMF_2.0

Option 2: you can add a hook to call your function that will add the menu item. This would be a little complex. Requires you to enter a couple of rows into the settings table for the hooks.
Here's the page with a list of hooks. http://wiki.simplemachines.org/smf/Integration_hooks
Here's a page to show you how they work. http://wiki.simplemachines.org/smf/Add_a_custom_action_using_integration_hooks

Option 3: you can also add your menu item in the index.template.php file where the template_menu() function. While it's looping through the menu array you can check to see if you're on the members menu item, and then append your child menu item to the child menu array. Draw back of this option is it only adds the menu item for the theme you add this code into.
IchBin™        TinyPortal

Arantor

Option 1 is no good because the ACP menu is not in Subs.php.

Option 3 for the same reason.

Option 2 is ideal but it requires using two separate hooks to activate the hooks (and they're different hooks to the main menu)... but I'm just trying to remember if the menu code in the admin panel actually allows for override URLs because you don't normally feed URLs at it, they're built out of the array structure itself.
Holder of controversial views, all of which my own.


IchBin™

Oops forgot he was talking about admin menu. Thanks for pointing that out.
IchBin™        TinyPortal

far2slow

reading this i am starting to think i have done things wrong i have just added the code into Admin.php, or is this being made more complex than it is ?

Arantor

You can add it to Admin.php directly but doing through hooks means 1) not changing files and 2) keeping the code cleanly delineated so maintenance will be easier in future (since upgrades have much less chance of breaking it)
Holder of controversial views, all of which my own.


far2slow

Lainaus käyttäjältä: Arantor - syyskuu 01, 2013, 05:17:44 IP
You can add it to Admin.php directly but doing through hooks means 1) not changing files and 2) keeping the code cleanly delineated so maintenance will be easier in future (since upgrades have much less chance of breaking it)

good to know, as i don't tend to send the stuff i write to the public domain so never had to deal with them situations. maybe something i should look into then, with many mods out there that do add things to core code i guess i have just gone about it the same way. maybe that is a discussion  for another day --> i am sure its already been covered  ;)

Advertisement: