Custom tabs - How do I add them to the Core (default) theme menu From Online Manual

Jump to: navigation, search

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.

In index.template.php

There are two ways to do this. This first method is the recommended one.

First method

Find:

 	if ($context['current_action'] == 'search2')
		$current_action = 'search';

Add After:

 	if ($context['current_action'] == 'chat')
		$current_action = 'chat';

Second Method

Find:

 	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.

 	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

 	// Show the [home] button.
	echo ($current_action=='home' || $context['browser']['is_ie4']) ? ' ' :  , '
				
					<a href="', $scripturl, '">' , $txt[103] , '</a>
				' , $current_action == 'home' ? '&nbsp;' : ;
  • $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 prints Home on the Main menu. As you see the variable is inside ' , , '. 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.

 	// Show the [chat] button.
	echo ($current_action=='chat' || $context['browser']['is_ie4']) ? '&nbsp;' :  , '
				
					<a href="', $scripturl, '?action=chat">Chat</a>
				' , $current_action == 'chat' ? '&nbsp;' : ;

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


For Support please take a look at this topic.



Advertisement: