News:

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

Main Menu

Add a new Button

Started by songoty, March 20, 2008, 09:40:52 PM

Previous topic - Next topic

songoty

How do you add new buttons in the new Smf 2.0.3 Beta? Iv searched the indextemplate.php and i cant fin the area.

BuЯЯЯЯaK

Subs.php

'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
),



metallica48423

#2
as the member above pointed out, the menu has been moved to Subs.php.

The block he posted is an example block for the home tab.

I may actually write a Doc up on this, just so we have it.  But or right now, let me explain this block.  The block parts are on the left, the explanation on the right for each line.


'home' => array(                        ## This is Just the Array Key -- this needs to be unique and different from all the others within this section.
     'title' => $txt['home'],           ## The text to appear on the tab -- you can use a variable as in the example or hardcode the text such as 'title' => 'My Text',
     'href' => $scripturl,              ## The URL to go to, again this can be a variable or a hardcoded string such as 'href' => 'http://blablah.com',
     'show' => true,                    ## Show this tab.  True shows it.  False Hides it.  Simple, eh? ( you can use a permission here as well ) :P
     'sub_buttons' => array(            ## The Sub Button Array, On future themes that support it, your sub buttons/dropdowns will go here. 
      ),                                ##  This array is empty -- but we need to end it anyways.
),                                      ## Make sure to end the main array itself
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Skhilled

Thanks for the tut, metallica48423. It is appreciated. :)

tpet96

Does this look correct to you?  It does not show up on our forums menu bar when I save like this and upload.  The portion in question is the one entitled "CHAT" :

{
$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
),
'chat' => array(
'title' => $txt['chat'],
'href' => 'http://ncogeo.com/forum/chat/amfichat.php',
'show' => true,
'sub_buttons' => array(
),
),
'help' => array(
'title' => $txt['help'],
'href' => $scripturl . '?action=help',
'show' => true,
'sub_buttons' => array(
),
),

metallica48423

is the variable $txt['chat'] set anywhere, such as a language file?

If you aren't using multiple language, you could just replace $txt['chat'] with 'chat',
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

tpet96

THANK YOU for that.  It works like a charm.  Again...thanks for bearing with me.  I'm a newb when it comes to some of this stuff...and can only learn by asking.

Atheo

Hi, great tut.

I am using the Custom Action Mod.  Is it possible to link to a custom action?  Would this be done with href=blah/blah.php?action=blah

I could just try this...but I am really new to this and would like to be sure before I do. 
Could you offer example code?

I am trying to change the home button to link to a custom page (action, i guess) and create a forum button that links to the forum page.

Thanks so much.

metallica48423

QuoteI am using the Custom Action Mod.  Is it possible to link to a custom action?  Would this be done with href=blah/blah.php?action=blah

'href' => 'http://example.com/path/index.php?action=blah';,
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Atheo

You are the man!  Thanks

One thing, now when I am in the board itself, the HOME button (link changed to custom action) remains highlighted.  How do I correct this?

$buttons = array(
'home' => array(
'title' =>'home',
'href' => 'http://fit-hub.com/index.php?action=index',
'show' => true,
'sub_buttons' => array(
),
),

                        'forum' => array(
'title' => 'forum',
'href' => 'http://fit-hub.com/index.php',
'show' => true,
'sub_buttons' => array(
),
),
                       

//Switched home and forum--^


'search' => array(
'title' => $txt['search'],
'href' => $scripturl . '?action=search',
'show' => $context['allow_search'],
'sub_buttons' => array(
),
),

Atheo

Any fix for this?  I have found a similar fix but not for 2.x

metallica48423

In Subs.php, try changing


// Default to home.
$current_action = 'home';


to

// Default to home.
$current_action = 'forum';
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Atheo

Did that.  Now when I am on HOME the FORUM button stays highlighted! ?

metallica48423

I see by visiting your site that you resolved this?

would you mind noting what change you made? I want to see if it is in line with the solution i may have found.  Thanks
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Atheo

If you mean did I resolve it?  Yes I did...I went back to 1.1.5

[SAP]Francis

What does sub_buttons?

Vehicles Forum

Founded By Francis Morissette

metallica48423

currently, it does nothing with the current theme

it is what defines the dropdowns for example with the theme we use here.
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

_Anthony_

metallica48423 can we set them up with the smf default?

metallica48423

the smf default theme doesn't have support for the dropdowns currently (the themes have to specifically support it.)  i'll see if i can find any information about adding it though.
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

_Anthony_


Advertisement: