TinyPortal

Development => Support => Topic started by: m3talc0re on March 18, 2008, 01:17:43 AM

Title: Problem with mainnav-active stuff...
Post by: m3talc0re on March 18, 2008, 01:17:43 AM
I'm making a new theme of mine TP compatible, but for some reason, I can't get the mainnav active stuff to work for "forum". When at the portal "home", "home" is active. When you go to "forum", "home" is still active, not "forum"...

Here's the original TP code for home and forum:

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

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


Here's my code:

// Show the [home] button.
echo '
<td valign="middle" class="mainnav' , $current_action == 'home' ? '_active' : '' , '">
<a href="', $scripturl, '">' , $txt[103] , '</a>
</td>';

// Show the [forum] button.
if($settings['TPortal_front_type']!='boardindex')
echo '
<td valign="middle" class="mainnav' , $current_action == 'forum' ? '_active' : '' , '">
<a href="', $scripturl, '?action=forum">'.$txt['tp-forum'].'</a>
</td>';


Any idea? On the default template, it works. On mine, it does not.

Thanks.
Title: Re: Problem with mainnav-active stuff...
Post by: IchBin on March 18, 2008, 03:28:25 AM
By default you should set $current_action = 'home'; I would put that code at the top of the template_menu function. Then if its actually anything else (like forum) then $current_action = 'forum';

Assign forum action by using php:
if (isset($_GET['board']) || isset($_GET['topic']))
$current_action = 'forum';


All other actions should already be defined in the array. I hope I explained that well. :)
Title: Re: Problem with mainnav-active stuff...
Post by: m3talc0re on March 18, 2008, 08:42:40 PM
OOOhh, okay, I see what you're saying. I didn't even notice that TP added some extra parts up in that "// Work out where we currently are." part. Thanks Ich.
Title: Re: Problem with mainnav-active stuff...
Post by: IchBin on March 19, 2008, 12:55:01 AM
No problem, glad you figured it out.