News: April 7, 2019 - TP Docs is now updated to Version 1.6.3...!

Search Articles


Search in titles
Search in article texts

Docs Navigation





Author Topic: How Do I Add A Forum Button Or Tab To My Themes?  (Read 10368 times)

Offline Xarcell

  • Full Member
  • ***
  • Posts: 137
How Do I Add A Forum Button Or Tab To My Themes?
« on: April 15, 2008, 05:59:13 PM »
Adding the Button/Tab varies depending on theme, but hopefully this guide will help point you in the right direction. You only need to edit your index.template.php file to add a button/tab.

First open your "index.template.php" file.

Then, you will need to add the button to the array. Towards the end of the index.template.php file, search for:
Code: [Select]
if (in_array($context['current_action'], array('links', 'search', 'admin', 'arcade','calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'tpadmin')))
$current_action = $context['current_action'];

You will need to add 'forum', to your button array, so that it will look something like this:
Code: [Select]
if (in_array($context['current_action'], array('forum', 'links', 'search', 'admin', 'arcade','calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'tpadmin')))
$current_action = $context['current_action'];

For Tab:
Next you will need to add the tab itself. Further to the end of the index.template.php file, search for code that looks similar to this:
Code: [Select]
// Show the [help] button.
echo ($current_action == 'help' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'help' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=help">' , $txt[119] , '</a>
</td>' , $current_action == 'help' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

You will need to add this forum tab snippet somewhere between each snippet of tab code:
Code: [Select]
if($settings['TPortal_front_type']!='boardindex')
// Show the [forum] button.
echo ($current_action=='forum' || $context['browser']['is_ie4']) ? '<td class="maintab_active_first">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action=='forum' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=forum">'.$txt['tp-forum'].'</a>
</td>' , $current_action=='forum' ? '<td class="maintab_active_last">&nbsp;</td>' : '';

For Button:
If you are adding a button, not a tab, you will need to search for code that looks similar to this:
Code: [Select]
// How about the [search] button?
if ($context['allow_search'])
echo '
<a href="', $scripturl, '?action=search">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/search.gif" alt="' . $txt[182] . '" style="margin: 2px 0;" border="0" />' : $txt[182]), '</a>', $context['menu_separator'];

Then add this somewhere between each button snippet:
Code: [Select]
// How about the [forum] button?
if($settings['TPortal_front_type']!='boardindex')
echo '        <a href="', $scripturl, '?action=forum">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/forum.gif" alt="Forum Index" style="margin: 2px 0;" border="0" />' : 'Forum Index'), '</a>', $context['menu_separator'];

Finally, just save and your done!

If you are confused about the differences between a "button" and a "tab", view the image attached below...




Doc Written By: Xarcell
« Last Edit: April 20, 2008, 07:39:24 PM by Xarcell »