Author Topic: [SMF 2 Tutorial] How To Add Tabs in SMF2  (Read 34236 times)

Offline Runic

  • Co-Founder
  • Hero Member
  • *****
  • Posts: 932
  • Metal!!
[SMF 2 Tutorial] How To Add Tabs in SMF2
« on: April 21, 2008, 11:53:02 AM »
In SMF2 the tabs have moved from the index.template.php, just so themes can work fully, these are now located in Sources/Subs.php

To add a new tab search for:

Code: [Select]
// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
now a few lines down you will see:

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

This is the start of the tabs, to add a new tab you would simply sort this, for this tutorial I will break each line up,

Code: [Select]
'home' => array(
This is simply call tag just for identifcation, it is important that you have this and the  ' ' or the tab will not work, for this tutorial we will assume that I have a custom page made up called Rules the above line would then be

Code: [Select]
'Rules' => array(
Next we shall look at the next line:

         
Code: [Select]
'title' => $txt['home'],
Yes this is a text string you could hardcode this but its more advisable to use a txt string specially if we are using another language besides for english.

            
Code: [Select]
'title' => $txt['rules'],For more information on txt strings please refer to Txt Strings (SMF Doc Site

now lets look at:

Code: [Select]
'href' => $scripturl,
This should be obvious to most people however this line is the link to the file this could be a direct link such as

Code: [Select]
'href' => 'http://www.smfthemes.org',

or a scripturl

Code: [Select]
'href' => $scripturl. '?action=rules',
Next we have the show tab or not for everyone to see you would leave as is

Code: [Select]
'show' => true,
but you could use

Code: [Select]
'show' => $context['allow_admin'],if wanting only admins

now for final line

Code: [Select]
'sub_buttons' => array(
),

unless you wish for extra options in that new tab then you dont need this.

So for final code for my nice new rules tab:

Code: [Select]
'Rules' => array(
'title' => $txt['rules'],
'href' => $scripturl . '?action=rules',
'show' => true,
),
« Last Edit: September 26, 2008, 03:58:38 PM by RunicWarrior »
Bryan "Runic" Deakin
Co-founder SMF Themes.org
Customiser Simple Machines LLC

Offline shadow82x

  • Designer
  • *
  • Posts: 32
  • Gender: Male
    • Egad Community
    • Email
Re: [Tutorial] How To Add Tabs in SMF2
« Reply #1 on: April 21, 2008, 07:05:58 PM »
Thanks for the tutorial Runic. It could really get some use around here! :D
- Shadow82x - SMF fanboy


Offline Runic

  • Co-Founder
  • Hero Member
  • *****
  • Posts: 932
  • Metal!!
Re: [Tutorial] How To Add Tabs in SMF2
« Reply #2 on: May 22, 2008, 03:40:07 PM »
ok its been updated the old end code was throwing an error
Bryan "Runic" Deakin
Co-founder SMF Themes.org
Customiser Simple Machines LLC

Offline Tyrsson

  • SMF Team
  • *
  • Posts: 46
    • SMF Themes.org
    • Email
Re: [SMF 2 Tutorial] How To Add Tabs in SMF2
« Reply #3 on: January 26, 2009, 11:47:09 PM »
Mind if I add on to this for drop menus??

Offline clapter

  • Newbie
  • *
  • Posts: 14
Re: [SMF 2 Tutorial] How To Add Tabs in SMF2
« Reply #4 on: January 29, 2009, 04:36:40 PM »
I spent about an hour figuring this out on my own. I should of joined this site sooner

Offline Jade

  • SMF Themes Friend
  • *
  • Posts: 311
    • Jades-World
    • Email
Re: [SMF 2 Tutorial] How To Add Tabs in SMF2
« Reply #5 on: January 29, 2009, 06:17:39 PM »
Mind if I add on to this for drop menus??


Go ahead, post a new tut for it :D

Offline Tyrsson

  • SMF Team
  • *
  • Posts: 46
    • SMF Themes.org
    • Email
Re: [SMF 2 Tutorial] How To Add Tabs in SMF2
« Reply #6 on: January 30, 2009, 01:29:11 AM »
Will do that tomorrow :) (I hope) been kinda busy the last few days....

Offline morganjames

  • Newbie
  • *
  • Posts: 2
Re: [SMF 2 Tutorial] How To Add Tabs in SMF2
« Reply #7 on: September 10, 2009, 08:15:19 PM »
hot! exactly what I was looking for

Offline jokes

  • Newbie
  • *
  • Posts: 1
    • Email
Re: [SMF 2 Tutorial] How To Add Tabs in SMF2
« Reply #8 on: December 31, 2009, 11:44:03 AM »
I try to do your tut but its not working to well for . I make the tab button it shows on the tab but when i click on it, it takes me to the forum? I want it to take me to a blank page so i can add some html or something. How do i do that?

Offline JBlaze

  • Operations Manager
  • *
  • Posts: 21
  • Gender: Male
    • JBlaze's Site
    • Email
Re: [SMF 2 Tutorial] How To Add Tabs in SMF2
« Reply #9 on: December 31, 2009, 01:26:31 PM »
I try to do your tut but its not working to well for . I make the tab button it shows on the tab but when i click on it, it takes me to the forum? I want it to take me to a blank page so i can add some html or something. How do i do that?


Can you paste the code you are using? If you want to make it open in a new window, just add target="_blank" to the URL.
Jason "JBlaze" Clemons
Customizer - Simple Machines | Operations Manager - SMF Themes

JBlaze.net | Facebook | Twitter

PM's for support will be put into the frying pan.

Offline christinedlrp

  • Newbie
  • *
  • Posts: 2
    • Email
Re: [SMF 2 Tutorial] How To Add Tabs in SMF2
« Reply #10 on: February 07, 2010, 01:22:37 AM »
I was able to add a new tab and it works but I was wondering if there if there's a way to make the link open a new window?

Offline christinedlrp

  • Newbie
  • *
  • Posts: 2
    • Email
Re: [SMF 2 Tutorial] How To Add Tabs in SMF2
« Reply #11 on: February 07, 2010, 10:54:49 PM »
Never mind I figured out how to do it....I added 'target' => '_blank', after the 'show' => true, line

 

SMFThemes.org would like to thank Network Redux for providing us with our hosting.
Templates: 3: index (Asude), Site (site_template), Display (default).
Sub templates: 10: init, html_above, site_outside_above, body_above, site_inside_above, main, site_inside_below, body_below, site_outside_below, html_below.
Language files: 1: index+Site+Modifications.english (Asude).
Style sheets: 0: .
Files included: 22 - 621KB. (show)
Cache hits: 11: 0.00540s for 13,038 bytes (show)
Queries used: 17.

[Show Queries]