Search articles


Search in titles
Search in article texts

Docs Navigation





How Do I Add A Forum Button Or Tab To My Themes?

Started by Ken., November 17, 2015, 01:02:20 PM

Previous topic - Next topic

Ken.

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