News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Post reply

The message has the following error or errors that must be corrected before continuing:
Warning: this topic has not been posted in for at least 30 days.
Unless you're sure you want to reply, please consider starting a new topic.
Note: this post will not display until it has been approved by a moderator.
Attachments: (Clear attachments)
Restrictions: 4 per post (4 remaining), maximum total size 192 KB, maximum individual size 128 KB
Uncheck the attachments you no longer want attached
Click or drag files here to attach them.
Other options
Verification:
Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:
Shortcuts: ALT+S post or ALT+P preview

Topic summary

Posted by SleePy
 - Apr 24, 2008, 03:04 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:

// 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:

'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,

'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

'Rules' => array(

Next we shall look at the next line:

          '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.

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

now lets look at:

'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

'href' => 'http://www.smfthemes.org',

or a scripturl

'href' => $scripturl. '?action=rules',

Next we have the show tab or not for everyone to see you would leave as is

'show' => true,

but you could use

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

now for final line

'sub_buttons' => array(

unless you wish for extra options in that new tab then you wouldnt need to change this.

So for final code for my nice new rules tab:

'Rules' => array(
'title' => $txt['rules'],
'href' => $scripturl . '?action=rules',
'show' => true,
'sub_buttons' => array(
),
),