Advertisement:

Author Topic: Add a new Button  (Read 19554 times)

Offline songoty

  • Newbie
  • *
  • Posts: 3
Add a new Button
« 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.

Offline BuЯЯЯЯaK

  • SMF Hero
  • ******
  • Posts: 2,124
  • Gender: Male
  • Burak
    • dinle sevgili
Re: Add a new Button
« Reply #1 on: March 20, 2008, 11:23:21 PM »
Subs.php

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


Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: Add a new Button
« Reply #2 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.

Code: [Select]
'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
« Last Edit: May 09, 2008, 02:43:49 PM by metallica48423 »
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

Quote
Microsoft 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
     

Offline Skhilled

  • Full Member
  • ***
  • Posts: 497
  • Gender: Male
  • When you stop learning, you stop living!
    • Docskillz
Re: Add a new Button
« Reply #3 on: March 22, 2008, 08:57:52 AM »
Thanks for the tut, metallica48423. It is appreciated. :)


Offline tpet96

  • Semi-Newbie
  • *
  • Posts: 31
Re: Add a new Button
« Reply #4 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" :

Code: [Select]
{
$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(
),
),

Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: Add a new Button
« Reply #5 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',
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

Quote
Microsoft 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
     

Offline tpet96

  • Semi-Newbie
  • *
  • Posts: 31
Re: Add a new Button
« Reply #6 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.

Offline Atheo

  • Jr. Member
  • **
  • Posts: 205
Re: Add a new Button
« Reply #7 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.

Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: Add a new Button
« Reply #8 on: May 16, 2008, 02:12:59 PM »
Quote
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

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

Quote
Microsoft 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
     

Offline Atheo

  • Jr. Member
  • **
  • Posts: 205
Re: Add a new Button
« Reply #9 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?

Code: [Select]
$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(
),
),

Offline Atheo

  • Jr. Member
  • **
  • Posts: 205
Re: Add a new Button
« Reply #10 on: May 16, 2008, 07:58:23 PM »
Any fix for this?  I have found a similar fix but not for 2.x

Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: Add a new Button
« Reply #11 on: May 17, 2008, 04:03:53 PM »
In Subs.php, try changing

Code: [Select]
// Default to home.
$current_action = 'home';

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

Quote
Microsoft 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
     

Offline Atheo

  • Jr. Member
  • **
  • Posts: 205
Re: Add a new Button
« Reply #12 on: May 17, 2008, 05:38:12 PM »
Did that.  Now when I am on HOME the FORUM button stays highlighted! ?

Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: Add a new Button
« Reply #13 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
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

Quote
Microsoft 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
     

Offline Atheo

  • Jr. Member
  • **
  • Posts: 205
Re: Add a new Button
« Reply #14 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

Offline [SAP]Francis

  • Full Member
  • ***
  • Posts: 543
  • Gender: Male
  • FastRides Owner and Founder
    • FastRides
Re: Add a new Button
« Reply #15 on: May 28, 2008, 12:18:38 PM »
What does sub_buttons?

Vehicles Forum

Founded By Francis Morissette

Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: Add a new Button
« Reply #16 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.
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

Quote
Microsoft 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
     

Offline _Anthony_

  • Full Member
  • ***
  • Posts: 547
Re: Add a new Button
« Reply #17 on: May 30, 2008, 11:12:12 PM »
metallica48423 can we set them up with the smf default?

Offline metallica48423

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,842
  • Gender: Male
  • Professional Multislacker!
    • Zentendo
Re: Add a new Button
« Reply #18 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.
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

Quote
Microsoft 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
     

Offline _Anthony_

  • Full Member
  • ***
  • Posts: 547
Re: Add a new Button
« Reply #19 on: May 30, 2008, 11:22:41 PM »
Ok thanks

Offline Nathaniel

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,117
  • Gender: Male
    • Verbtest.com
Re: Add a new Button
« Reply #20 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
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.