Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: songoty on March 20, 2008, 09:40:52 PM

Title: Add a new Button
Post by: songoty on March 20, 2008, 09:40:52 PM
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.
Title: Re: Add a new Button
Post by: BuЯЯЯЯaK on March 20, 2008, 11:23:21 PM
Subs.php

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


Title: Re: Add a new Button
Post by: metallica48423 on March 21, 2008, 04:44:22 AM
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
Title: Re: Add a new Button
Post by: Skhilled on March 22, 2008, 08:57:52 AM
Thanks for the tut, metallica48423. It is appreciated. :)
Title: Re: Add a new Button
Post by: tpet96 on May 09, 2008, 05:57:03 PM
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(
),
),
Title: Re: Add a new Button
Post by: metallica48423 on May 10, 2008, 02:32:46 AM
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',
Title: Re: Add a new Button
Post by: tpet96 on May 10, 2008, 07:03:04 AM
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.
Title: Re: Add a new Button
Post by: Atheo on May 16, 2008, 02:06:19 PM
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.
Title: Re: Add a new Button
Post by: metallica48423 on May 16, 2008, 02:12:59 PM
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',
Title: Re: Add a new Button
Post by: Atheo on May 16, 2008, 02:28:57 PM
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(
),
),
Title: Re: Add a new Button
Post by: Atheo on May 16, 2008, 07:58:23 PM
Any fix for this?  I have found a similar fix but not for 2.x
Title: Re: Add a new Button
Post by: metallica48423 on May 17, 2008, 04:03:53 PM
In Subs.php, try changing


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


to

// Default to home.
$current_action = 'forum';
Title: Re: Add a new Button
Post by: Atheo on May 17, 2008, 05:38:12 PM
Did that.  Now when I am on HOME the FORUM button stays highlighted! ?
Title: Re: Add a new Button
Post by: metallica48423 on May 27, 2008, 11:20:16 PM
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
Title: Re: Add a new Button
Post by: Atheo on May 28, 2008, 10:49:49 AM
If you mean did I resolve it?  Yes I did...I went back to 1.1.5
Title: Re: Add a new Button
Post by: [SAP]Francis on May 28, 2008, 12:18:38 PM
What does sub_buttons?
Title: Re: Add a new Button
Post by: metallica48423 on May 28, 2008, 03:16:08 PM
currently, it does nothing with the current theme

it is what defines the dropdowns for example with the theme we use here.
Title: Re: Add a new Button
Post by: _Anthony_ on May 30, 2008, 11:12:12 PM
metallica48423 can we set them up with the smf default?
Title: Re: Add a new Button
Post by: metallica48423 on May 30, 2008, 11:16:21 PM
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.
Title: Re: Add a new Button
Post by: _Anthony_ on May 30, 2008, 11:22:41 PM
Ok thanks
Title: Re: Add a new Button
Post by: Nathaniel on June 07, 2008, 02:44:04 AM
Have a read of the post below,I believe that it properly answers the question.

http://www.simplemachines.org/community/index.php?topic=239787.msg1569432#msg1569432