MyBB Community Forums

Full Version: Add Menu Link
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
im creating a plugin and I want it to add a menu link automatically once its installed and remove it when it is uninstalled/deactivated. Can anyone help me please?

Thank You
anyone? Sad
You can use our plugin here for free :

My Custom Navigation Links

Wink

If you prefer help just PM me...
exdiogene, thank you, but Im making a plugin, so i need it to make a menu link automatically once someone installs the plugin on their forums. Get me?
Yes, i can still help you with your problem if you tell me what you did and what did not worked?
http://mods.mybboard.net/view/mybb-quran

thats version 1 of the mod.(i made it)
in the next version I want it to add a menu link. I have not done anything because I am a beginner in MyBB coding, and I do not know where to start.
We need to know WHERE you want it. Different menus are built in different ways. Do you mean a UserCP Menu? And AdminCP Menu?
(2010-01-05, 11:34 PM)ralgith Wrote: [ -> ]We need to know WHERE you want it. Different menus are built in different ways. Do you mean a UserCP Menu? And AdminCP Menu?

where it says "Search, Memberlist, Calendar, Help" at the top
(2010-01-05, 11:58 PM)shaks786 Wrote: [ -> ]
(2010-01-05, 11:34 PM)ralgith Wrote: [ -> ]We need to know WHERE you want it. Different menus are built in different ways. Do you mean a UserCP Menu? And AdminCP Menu?

where it says "Search, Memberlist, Calendar, Help" at the top

Ok, so a toplink then Smile

This is in the header template
To add it from a plugin you need to use the find_replace_templatesets function in your plugin

For example
require_once MYBB_ROOT."inc/adminfunctions_templates.php";

find_replace_templatesets("header", '#'.preg_quote('<li><a href="{$mybb->settings[\'bburl\']}/memberlist.php"><img src="{$mybb->settings[\'bburl\']}/{$theme[\'imgdir\']}/toplinks/memberlist.gif" alt="" title="" />{$lang->toplinks_memberlist}</a></li>').'#', '<li><a href="{$mybb->settings['bburl']}/memberlist.php"><img src="{$mybb->settings['bburl']}/{$theme['imgdir']}/toplinks/memberlist.gif" alt="" title="" />{$lang->toplinks_memberlist}</a></li>WHATEVER YOU WANT TO ADD HERE');

Would go into your activate routine and put the link between member list and calendar

While
require_once MYBB_ROOT."inc/adminfunctions_templates.php";

find_replace_templatesets("header", '#'.preg_quote('<li><a href="{$mybb->settings[\'bburl\']}/memberlist.php"><img src="{$mybb->settings[\'bburl\']}/{$theme[\'imgdir\']}/toplinks/memberlist.gif" alt="" title="" />{$lang->toplinks_memberlist}</a></li>WHATEVER YOU ADDED HERE').'#', '<li><a href="{$mybb->settings['bburl']}/memberlist.php"><img src="{$mybb->settings['bburl']}/{$theme['imgdir']}/toplinks/memberlist.gif" alt="" title="" />{$lang->toplinks_memberlist}</a></li>', 0);

Would go into your deactivate routine. Now notice how theres an extra field (a 0 for the value) on the removal. Don't forget that or it won't work right.
You can find an easier example at my plugin here. Download it and check out the code I have used.

http://www.forumsecurity.eu/showthread.php?tid=12