Menu Tab not showing 'active' on Frontpage

Started by RogueTrooper, April 19, 2011, 12:45:41 AM

Previous topic - Next topic

RogueTrooper

Hey guys,
I've spent a few days looking through the search function for an answer to this but haven't found one as yet (if there is one I'm sorry!).

My forum is at hxxp:menefrego.co.uk/community [nonactive]

It's running SMF1.1.11 with Tinyportal 1.0 Beta 5-1 and has the AF316 theme.

I followed the instructions to add a new menu tab as found here. However from what I've read the reason that the menu tab (HOME) isn't highlighting when active is because it is not actually an action and is operating outside the forum.

Is there any way to make the HOME button active when on the TinyPortal Frontpage?

The code I'm using is as follows:

$current_action = 'BoardIndex';
   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')))
   if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm')))
      $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';
//Dan additions for adding menu items as current actions (TP)
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 2)
      $current_action = 'aboutus';
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 3)
      $current_action = 'history';
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 4)
      $current_action = 'events';
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 5)
      $current_action = 'gallery';


I tried using the following advice from a forum poster who seemed to have a similar issue in the above linked post:

Quote from: FlashUK1983 on May 23, 2009, 07:34:05 PM
Just thought I'd drop by and let you know, I've solved my problem.

Instead of using
   if ($context['current_action'] == 'frontpage')
      $current_action = 'frontpage';


I used the following instead

        if ($_SERVER['REQUEST_URI']=='/')
$current_action = 'frontpage';


However it doesn't seem to have had any effect when I've used it.

Has anyone got any thoughts or encountered this before?

Thank you,

Rogue Trooper

Illori

i would suggest you contact tinyportal support for further help. they will be able to help you the best to get this resolved.

RogueTrooper

Illori,
I have asked there as well now - however my hope is that someone on here may have a fix as well since the issue isn't TinyPortal but rather having an active menu button for a page that is not an action, something I'd hoped occurs at least often enough for someone to know what to do ha ha.

I'm new to php and any help anyone can give would be fantastic.

Illori

since you are using tinyportal to create the page it may require custom code that they would know best out of anyone.

RogueTrooper

It's worth a shot purely in the event they do have a speciic custom code. If they have an answer I'll be sure to update this post as well since the custom code would have far more use than merely TP.

Likewise, and again, if anyone does know of a custom code that could be utilised I'll update there as well. Share the wealth and so on ha ha.

I'm surprised the request_uri didn't work. That code was shown to work, however on a custom php page.

Cheers,
RT

mashby

It's merely a matter of adding some code to the template_menu() function. Based on the parsing of that mod for 1.1.13 (you should really update to this version):
Find:
if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm')))
Replace With:
if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'forum', 'tpadmin')))
Find:
$current_action = 'search';
Replace With:

if (isset($_GET['dl']))
$current_action = 'dlmanager';

if (isset($_GET['board']) || isset($_GET['topic']) || $context['current_action']=='forum')
$current_action = 'forum';

if ($context['current_action']=='tpadmin')
$current_action = 'admin';

It looks like you have already added the tab part. Did you also do the stuff above?
Always be a little kinder than necessary.
- James M. Barrie

RogueTrooper

mashby,

As it stands now I have the following code;

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')))
   if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'forum', 'tpadmin')))
      $current_action = $context['current_action'];
   if (isset($_GET['dl']))
      $current_action = 'dlmanager';

   if (isset($_GET['board']) || isset($_GET['topic']) || $context['current_action']=='Forum')
      $current_action = 'Forum';

   if ($context['current_action']=='tpadmin')
      $current_action = 'admin';
   if ($context['current_action'] == 'theme')
      $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
//Dan additions for adding menu items as current actions (TP)
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 2)
      $current_action = 'aboutus';
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 3)
      $current_action = 'history';
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 4)
      $current_action = 'events';
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 5)
      $current_action = 'gallery';

   // 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 , '"> </td>';

   // Show the [home] button.
   echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'home' ? 'active_back' : 'back' , '">
               <a href="http://menefrego.co.uk/community/">' , $txt[103] , '</a>
            </td>' , $current_action == 'home' ? '<td class="maintab_active_' . $last . '"> </td>' : '';

   // Show the [forum] button.
   echo ($current_action == 'Forum' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '"> </td>' : '' , '
            <td valign="top" class="maintab_' , $current_action == 'Forum' ? 'active_back' : 'back' , '">
               <a href="', $scripturl, '?action=forum">' , $txt['D01'] , '</a>
            </td>' , $current_action == 'Forum' ? '<td class="maintab_active_' . $last . '"> </td>' : '';


As you can see on the webpage the code is registering home and all the other links as active but the forum is now registering as Home.

I added what you suggested as well as returning BoardIndex to home. Any suggestions from here?

Also, thank you again for your help - it's very much appreciated!

Rogue Trooper
P.S - Yes, I added the tab. I've got it in the code above for your perusal :)

RogueTrooper

Also - the same appears to be occuring on the Profile tab and Messaging (both registering as Home when active) - does this mean perhaps that the Home action is coded wrong?

RogueTrooper

#8
Sorry for the Triple Post!

EDIT: If you read my previous post please ignore - causes a lot of errors.

Got it all working with the following. Some notes about what and why and how and even details on me not knowing what fixed it are available hxxp:www.tinyportal.co.uk/index.php?topic=33857.0 [nonactive].

// 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')))
   if (in_array($context['current_action'], array('search', 'admin', 'calendar', 'profile', 'mlist', 'register', 'login', 'help', 'pm', 'Forum', 'tpadmin')))
      $current_action = $context['current_action'];

  if (isset($_GET['dl']))
      $current_action = 'dlmanager';

   if (isset($_GET['board']) || isset($_GET['topic']) || $context['current_action']=='forum')
      $current_action = 'forum';

   if ($context['current_action']=='tpadmin')
      $current_action = 'admin';

   if ($context['current_action'] == 'theme')
      $current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';

//Dan additions for adding menu items as current actions (TP)
   //if ($context['current_action']=='')
      //$current_action = 'home';
   if ($context['current_action']=='calendar')
      $current_action = 'calendar';
   if ($context['current_action']=='pm')
      $current_action = 'pm';
   if ($context['current_action']=='profile')
      $current_action = 'profile';
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 2)
      $current_action = 'aboutus';
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 3)
      $current_action = 'history';
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 4)
      $current_action = 'events';
   if (isset($_REQUEST['page']) && $_REQUEST['page'] == 5)
      $current_action = 'gallery';
   if (isset($_REQUEST['cat']) && $_REQUEST['cat'] == 8)
      $current_action = 'home';




Advertisement: