How to add extra menu buttons to Nav bar

Written by Mick in Tutorials on 02 Mar 2010

To add external links to the menu nav bar.....

Go to:

Sources/Subs.php


Find:
'home' => array(
            'title' => $txt['home'],
            'href' => $scripturl,
            'show' => true,
            'sub_buttons' => array(
            ),
         ),
         'help' => array(
            'title' => $txt['help'],
            'href' => $scripturl . '?action=help',
            'show' => true,
            'sub_buttons' => array(
            ),
         ),



Lets add an external link after "home".

'home' => array(
            'title' => $txt['home'],
            'href' => $scripturl,
            'show' => true,
            'sub_buttons' => array(
            ),
         ),
         'mysite' => array(
            'title' => 'mysite',
            'href' => 'http://www.mysite.example',
            'show' => true,
            'sub_buttons' => array(
            ),
         ),
         'help' => array(
            'title' => $txt['help'],
            'href' => $scripturl . '?action=help',
            'show' => true,
            'sub_buttons' => array(
            ),
         ),


Replace "mysite" with the actual name of the button.
Replace the URL with the actual URL of the page is intended for.
Mick is an American theme designer for Simple Machines Forum software currently living in South Florida, USA. He runs idesignSMF and started tinkering with SMF in 2006 where he created several SMF forums of his own before he founded idesignSMF in 2009 to which he is dedicated full time.
    

12 Comments

Also, to add on to this, you can make the button selected on the forum menu instead of having home selected by doing the following:

Find in Subs.php:
elseif ($context['current_action'] == 'search2')
$current_action = 'search';


Add after:
elseif ($context['current_action'] == 'mysite')
$current_action = 'mysite';


And of course replace 'mysite' with whatever you decided to call your custom button.
#1
Certain themes (DSv4 for instance) has it in the index.template.php since it uses a custom menu..  The edit is a bit different.

If anyone is interested, I'll post up the edits as well.
#3
Can I use this to add a  link to my advertisements page which was made using the portals pages?
#4
Quote from: Brack1 on 23 Mar 2010
Can I use this to add a  link to my advertisements page which was made using the portals pages?

Yes...

like this...

         'advertisement' => array(
            'title' => 'advertisement',
            'href' => 'URL of the advertisement page goes here',
            'show' => true,
            'sub_buttons' => array(
            ),
         ),
#5
Thanks Mick

:-[

Oops I just cheated by using a custom tab mod.

The banners need resizing tho.

http://www.mkaware.co.uk/index.php?page=page2734
#6
The images are too big.  Theyre at 480.   The code is setup to hold banners with 460 in size.
#7
Have made a couple differences to the page now.
#8
Good start but if i click those images.... they'll take me to your photobucket account. :-\

If youre doing just that, i would just add text to start ;)
#9
Would the html link be enough?
#10
Hope I am not breaking rules by posting in this thread its old :)

I have most of my forum how I want it and now have to add some buttons.

I am running simple portal and trying to locate the code

Is this the code i need below in subs.php, I want to delete help and search and add 2 more.

      $buttons = array(
         'home' => array(
            'title' => $txt['home'],
            'href' => $modSettings['sp_portal_mode'] == 3 && empty($context['disable_sp']) ? $modSettings['sp_standalone_url'] : $scripturl,
            'show' => true,
            'sub_buttons' => array(
            ),
            'is_last' => $context['right_to_left'],
         ),
         'forum' => array(
            'title' => empty($txt['sp-forum']) ? 'Forum' : $txt['sp-forum'],
            'href' => $scripturl . ($modSettings['sp_portal_mode'] == 1 && empty($context['disable_sp']) ? '?action=forum' : ''),
            'show' => in_array($modSettings['sp_portal_mode'], array(1, 3)) && empty($context['disable_sp']),
            'sub_buttons' => array(
            ),
         ),
         'help' => array(
            'title' => $txt['help'],
            'href' => $scripturl . '?action=help',
            'show' => true,
            'sub_buttons' => array(
            ),
         ),
         'search' => array(
            'title' => $txt['search'],
            'href' => $scripturl . '?action=search',
            'show' => $context['allow_search'],
            'sub_buttons' => array(
            ),
#11
Yes, just set to 'false' to items you dont want to show.

Like this:
         'help' => array(
            'title' => $txt['help'],
            'href' => $scripturl . '?action=help',
            'show' => false,
            'sub_buttons' => array(
            ),
         ),
#12

Get more stuff like this

Subscribe to our mailing list and get interesting content and updates.