Advertisement:

Author Topic: [1.1] How to add tabs to Core (NDT)?  (Read 358470 times)

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
[1.1] How to add tabs to Core (NDT)?
« on: December 31, 2005, 04:21:57 PM »
For a more up to date version of this please see the doc site
SMF 2.0? See here instead

The way you add links to the menu has changed in the new default theme.  You will need to make several other steps in order to make the tabs work like they should.  Here are the steps required to add a menu item.  For this tutorial we are going to be adding a chat link.

1. In index.template.php
There are two ways to do this.  This first method is the recomemded one.

First method
Code: (Find) [Select]
if ($context['current_action'] == 'search2')
$current_action = 'search';

Code: (Add After) [Select]
if ($context['current_action'] == 'chat')
$current_action = 'chat';

Second Method
Code: (Find) [Select]
if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm')))
As you can see it has a list of the actions in the menu.  What we are going to do is add , 'chat' after 'pm'.  Each action in the array is separated by a comma and enclosed in single quotes (').  It should look like this.

Code: [Select]
if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'chat')))

The next step is adding the link itself.  This is an example of the home menu.

2. In the same file
Code: [Select]
// Show the [home] button.
echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'home' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '">' , $txt[103] , '</a>
</td>' , $current_action == 'home' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


  • $current_action=='home' - is what sets the tab for the current actions.  As you can see it is defined in 3 instances.  You will need to change it for all three of them.
  • ' , $txt[103] , ' - is the text string that 'Home'.  As you see the variable is insde ' , , '.  The reason for this is because it's inside an echo.  If you are going to hard code the name in the menu you do not need to put ' , , ' around it.

This is how it should look with the made changes.

Code: [Select]
// Show the [chat] button.
echo ($current_action=='chat' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'chat' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=chat">Chat</a>
</td>' , $current_action == 'chat' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


If you want to be neat about it and add support for other languages add this string to /Themes/default/languages/index.english.php and to any other language file that you want to add it to.  ie. /Themes/default/languages/index.{language}.php and change Chat to the translated string.
$txt['chat'] = 'Chat';


EDIT
I cleaned this tutorial up a bit.

If you find it a bit confusing please let me know so that I can recide it :)

-JayBachatero
« Last Edit: January 15, 2009, 05:12:45 PM by H »
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline J. Williams

  • SMF Hero
  • ******
  • Posts: 1,535
  • Gender: Male
  • Don't ask me what DiCB stands for!
    • ByMoi
Re: How to add tabs to Core (NDT).
« Reply #1 on: December 31, 2005, 07:13:17 PM »
Best sticky this as its very important
Joshua Jon Williams
Back in Action.

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to add tabs to Core (NDT).
« Reply #2 on: December 31, 2005, 07:15:20 PM »
Meh too many stickies in this board.  Let it float around.  People will find it and it's not that difficult to add them ;)

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline J. Williams

  • SMF Hero
  • ******
  • Posts: 1,535
  • Gender: Male
  • Don't ask me what DiCB stands for!
    • ByMoi
Re: How to add tabs to Core (NDT).
« Reply #3 on: December 31, 2005, 08:03:51 PM »
Theres only 4
Joshua Jon Williams
Back in Action.

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to add tabs to Core (NDT).
« Reply #4 on: December 31, 2005, 08:07:36 PM »
Yea they were just moved :)  Also this topic was added to http://www.simplemachines.org/community/index.php?topic=11481.msg100701#msg100701.

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline J. Williams

  • SMF Hero
  • ******
  • Posts: 1,535
  • Gender: Male
  • Don't ask me what DiCB stands for!
    • ByMoi
Re: How to add tabs to Core (NDT).
« Reply #5 on: December 31, 2005, 08:19:00 PM »
Ok
Joshua Jon Williams
Back in Action.

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to add tabs to Core (NDT).
« Reply #6 on: December 31, 2005, 08:27:39 PM »
If it becomes an issue it will be put as a sticky for a week or two :)

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Simplemachines Cowboy

  • Jr. Member
  • **
  • Posts: 354
  • KA-CLICK
    • The Open Range
Re: How to add tabs to Core (NDT).
« Reply #7 on: December 31, 2005, 10:53:54 PM »
Mine is close:
Code: [Select]
// Show the [chat] button.
if ($context['user']['is_logged'])
echo ($current_action=='chat' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'chat' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=chat">' , $txt[100] , '</a>
</td>' , $current_action == 'chat' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

You'll notice I made a new $txt[100] that says 'Chat' & put it in index.english

Cowboy
My SMF forum: The Open Range

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to add tabs to Core (NDT).
« Reply #8 on: December 31, 2005, 10:55:23 PM »
Yeah it's better to add it to the language files than hardcoding the text to the link :)  make sure that $txt[100] is not used some where else.

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Simplemachines Cowboy

  • Jr. Member
  • **
  • Posts: 354
  • KA-CLICK
    • The Open Range
Re: How to add tabs to Core (NDT).
« Reply #9 on: December 31, 2005, 11:11:14 PM »
Since I'm currently on a test board I didn't scan EVERYWHERE for another $txt[100] but it seems to work.

A little OT but I plan to do a tutorial showing how to add everything to integrate Flashchat into RC 2. It's time to update the old one.
My SMF forum: The Open Range

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to add tabs to Core (NDT).
« Reply #10 on: December 31, 2005, 11:33:32 PM »
For things like this I would suggest that you use custom strings like $txt['chat_1'] and so on.  To prevent errors and so on.

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline russ skinner

  • Semi-Newbie
  • *
  • Posts: 57
Re: How to add tabs to Core (NDT).
« Reply #11 on: January 01, 2006, 06:14:58 PM »
I would like to add a gallery button to link to a coppermine gallery (to open in a seperate window) and have the button only visible once the user has logged on to the forum. In index.template.php I've modified the list of actions as follows:

Quote
   if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'gallery')))

but I am unsure how to code the link.

My forum is at http://www.srcmc.co.uk/forum/index.php and my gallery at http://www.srcmc.co.uk/gallery/index.php

Can anybody please help.

Many thanks

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to add tabs to Core (NDT).
« Reply #12 on: January 01, 2006, 06:21:16 PM »
Add if ($context[&#39;user&#39;][&#39;is_logged&#39;]) Before the button like this.


	
// Show the [chat] button.
	
if (
$context[&#39;user&#39;][&#39;is_logged&#39;])
	
echo (
$current_action==&#39;chat&#39; || $context[&#39;browser&#39;][&#39;is_ie4&#39;]) ? &#39;<td class="maintab_active_&#39; . $first . &#39;">&nbsp;</td>&#39; : &#39;&#39; , &#39;
	
	
	
	
<
td valign="top" class="maintab_&#39; , $current_action == &#39;chat&#39; ? &#39;active_back&#39; : &#39;back&#39; , &#39;">
	
	
	
	
	
<
a href="&#39;, $scripturl, &#39;">Chat</a>
	
	
	
	
</
td>&#39; , $current_action == &#39;chat&#39; ? &#39;<td class="maintab_active_&#39; . $last . &#39;">&nbsp;</td>&#39; : &#39;&#39;;


-JayBachatero
« Last Edit: January 01, 2006, 06:27:31 PM by JayBachatero »
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline russ skinner

  • Semi-Newbie
  • *
  • Posts: 57
Re: How to add tabs to Core (NDT).
« Reply #13 on: January 01, 2006, 06:49:44 PM »
Many thanks.

It works perfectly.

Russell

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to add tabs to Core (NDT).
« Reply #14 on: January 01, 2006, 06:50:34 PM »
You're welcome.

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline TarantinoArchives

  • Full Member
  • ***
  • Posts: 442
  • Gender: Male
  • Call it, friendo
    • The Quentin Tarantino Archives
Re: How to add tabs to Core (NDT).
« Reply #15 on: January 05, 2006, 06:41:58 PM »
nice tutorial. greetings.

Offline Gargoyle

  • Sophist Member
  • *****
  • Posts: 1,148
  • Gender: Male
    • South Side Street Cars
Re: How to add tabs to Core (NDT).
« Reply #16 on: January 08, 2006, 01:40:32 PM »
How do I make it link to an offsite URL... Like a Gallery or another website all together ?

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to add tabs to Core (NDT).
« Reply #17 on: January 08, 2006, 02:30:26 PM »
Just edit the href tag. <a href="', $scripturl, '?action=chat">Chat</a>.  If you are making it to an outside site you dont have to do the action stuff in if (in_array($context['current_action'], array('search',...

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Offline Gargoyle

  • Sophist Member
  • *****
  • Posts: 1,148
  • Gender: Male
    • South Side Street Cars
Re: How to add tabs to Core (NDT).
« Reply #18 on: January 08, 2006, 02:59:28 PM »
Thanks for the info!!

Offline JayBachatero

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 19,562
  • Gender: Male
    • @jaycreations on Twitter
    • JayBachatero.com
Re: How to add tabs to Core (NDT).
« Reply #19 on: January 08, 2006, 03:11:11 PM »
You're welcome.

-JayBachatero
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert