News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

[1.1] How to add tabs to Core (NDT)?

Started by JayBachatero, December 31, 2005, 04:21:57 PM

Previous topic - Next topic

Gargoyle

I think I figured it out... The URL needs to have an action attached to it in order for the menu to pick up on which tab to highlight. So I manually added the action to the URL and that has seemed to do the trick.

Thanks for your help and if you come up with a better way to do this please let me know as I would be interested in making this a bit better. ;D

aussieholden

I can't find this file "index.template.php" were is it located. ?

aussieholden


Acf

Quote from: JayBachatero on February 05, 2006, 07:42:24 PM
I'll take a closer look into this when I get a chance.

I geuss its shooting the variable in the header and change the header like if it where the ssi file and changing the tabs area will doo it. :P
still have to find out if it works :D
Sigh...

Acf

the ssi file with header with active tabs:
<?php
require_once('SSI.php');
template_main_above($current_action 'gallery')
?>


index.template.php

find:
function template_main_above()

replace:
function template_main_above($current_action = 'home')

find:
global $context, $settings, $options, $scripturl, $txt, $modSettings;

replace:
global $context, $settings, $options, $scripturl, $txt, $modSettings;

$current_action = $current_action;


find:
// Show the menu here, according to the menu sub template.
template_menu();


replace:
// Show the menu here, according to the menu sub template.
template_menu($current_action = $current_action);


find:
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

// Work out where we currently are.
$current_action = 'home';


replace:
function template_menu($current_action = 'home')
{
global $context, $settings, $options, $scripturl, $txt;

// Work out where we currently are.



this should do it ;)
Sigh...

IceBear

I managed to add a new button at www.nim.se/smf
But the button does not have the blue background ??
What did I do wrong ?

JayBachatero

Can you please post the block of code in the template_menu funtion?
Follow me on Twitter

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

IceBear

Is it this you mean ?

// Show the [main] button.
   echo ($current_action=='main' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'main' ? 'active_back' : 'main' , '">
               <a href="http://www.nim.se">Hem</a>
            </td>' , $current_action == 'main' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

JayBachatero

Follow me on Twitter

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

IceBear

#69
Might be better if I email you the file :)


// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
global $context, $settings, $options, $scripturl, $txt;

// Work out where we currently are.
$current_action = 'home';
if (in_array($context['current_action'], array('admin', 'ban', 'boardrecount', 'cleanperms', 'detailedversion', 'dumpdb', 'featuresettings', 'featuresettings2', 'findmember', 'maintain', 'manageattachments', 'manageboards', 'managecalendar', 'managesearch', 'membergroups', 'modlog', 'news', 'optimizetables', 'packageget', 'packages', 'permissions', 'pgdownload', 'postsettings', 'regcenter', 'repairboards', 'reports', 'serversettings', 'serversettings2', 'smileys', 'viewErrorLog', 'viewmembers')))
$current_action = 'admin';
if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'main')))
$current_action = $context['current_action'];
if ($context['current_action'] == 'search2')
$current_action = 'search';
if ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';

// Are we using right-to-left orientation?
if ($context['right_to_left'])
{
$first = 'last';
$last = 'first';
}
else
{
$first = 'first';
$last = 'last';
}

// Show the start of the tab section.
echo '
<table cellpadding="0" cellspacing="0" border="0" style="margin-left: 10px;">
<tr>
<td class="maintab_' , $first , '">&nbsp;</td>';

// Show the [main] button.
echo ($current_action=='main' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'main' ? 'active_back' : 'main' , '">
<a href="http://www.nim.se">Hem</a>
</td>' , $current_action == 'main' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

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

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

// How about the [search] button?
if ($context['allow_search'])
echo ($current_action == 'search' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'search' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=search">' , $txt[182] , '</a>
</td>' , $current_action == 'search' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// Is the user allowed to administrate at all? ([admin])
if ($context['allow_admin'])
echo ($current_action == 'admin' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'admin' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=admin">' , $txt[2] , '</a>
</td>' , $current_action == 'admin' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// Edit Profile... [profile]
if ($context['allow_edit_profile'])
echo ($current_action == 'profile' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'profile' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=profile">' , $txt[79] , '</a>
</td>' , $current_action == 'profile' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// Go to PM center... [pm]
if ($context['user']['is_logged'] && $context['allow_pm'])
echo ($current_action == 'pm' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'pm' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=pm">' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a>
</td>' , $current_action == 'pm' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// The [calendar]!
if ($context['allow_calendar'])
echo ($current_action == 'calendar' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'calendar' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=calendar">' , $txt['calendar24'] , '</a>
</td>' , $current_action == 'calendar' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// the [member] list button
if ($context['allow_memberlist'])
echo ($current_action == 'mlist' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'mlist' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=mlist">' , $txt[331] , '</a>
</td>' , $current_action == 'mlist' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


// If the user is a guest, show [login] button.
if ($context['user']['is_guest'])
echo ($current_action == 'login' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'login' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=login">' , $txt[34] , '</a>
</td>' , $current_action == 'login' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


// If the user is a guest, also show [register] button.
if ($context['user']['is_guest'])
echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=register">' , $txt[97] , '</a>
</td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'logout' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
</td>' , $current_action == 'logout' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';

// The end of tab section.
echo '
<td class="maintab_' , $last , '">&nbsp;</td>
</tr>
</table>';

}


EDIT: Used the code tag

JayBachatero

You have
<td valign="top" class="maintab_' , $current_action == 'main' ? 'active_back' : 'main' , '">
supposed to be
<td valign="top" class="maintab_' , $current_action == 'main' ? 'active_back' : 'back' , '">


   // Show the [main] button.
   echo ($current_action=='main' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'main' ? 'active_back' : 'main' , '">
               <a href="http://www.nim.se">Hem</a>
            </td>' , $current_action == 'main' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';



   // Show the [main] button.
   echo ($current_action=='main' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'main' ? 'active_back' : 'back' , '">
               <a href="http://www.nim.se">Hem</a>
            </td>' , $current_action == 'main' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
Follow me on Twitter

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

IceBear

Ahh, I missed that, may eyes must have been sour...

Thank you :)

JayBachatero

Yea it happens.  The first time I saw it iI couldn't spot the difference then I found it :)

-JayBachatero
Follow me on Twitter

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

Gargoyle

ACF ....

Was your post directed at me ?

Acf

Quote from: Gargoyle on February 08, 2006, 11:01:31 PM
ACF ....

Was your post directed at me ?

jup it was but i know what you meant.

You post inspired me to look for better solution... and i did find it :)
Sigh...

ladyshanae

Is there a way to make the tabs stretch with longer names instead of drop down to a second line and have the tabs looking short and fat versus long and skinny?

Does that make sense? lol

JayBachatero

It shouldn't go to a second line.  How long is the text?
Follow me on Twitter

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

Gargoyle

Quote from: ªcF on February 09, 2006, 02:45:41 PM
Quote from: Gargoyle on February 08, 2006, 11:01:31 PM
ACF ....

Was your post directed at me ?

jup it was but i know what you meant.

You post inspired me to look for better solution... and i did find it :)


Well thank you... ;D

ladyshanae

The longest text I had said:

HPRPG Official Store

I finally shortened it to store until I can work out how to keep it from dropping down.

Redeye

I've made all the changes to index.template.php and index.english.php and it worked OK.
I now have the menu item showing correctly.
The menu item I have created is for a gallery and it is using the action=gallery in the code.
How to I create this gallery "action" so that it will go to my Coppermine album?
TIA

Advertisement: