Advertisement:

Author Topic: Issue with navigational menu and custom theme.  (Read 1815 times)

Offline LC

  • Full Member
  • ***
  • Posts: 508
  • Gender: Female
  • Chaos is the score upon which reality is written.
Issue with navigational menu and custom theme.
« on: July 21, 2009, 03:57:15 PM »
I am having an issue with a custom theme and the navigational menu with a 1.1.10 smf version forum. When I added two features/mods to the menu I get this,

Screen shot here-

Obviously the gallery and chat button are not the same as the rest of the list. (Those are two mods I added to the forum)

Here is the navigational menu code from index.template.php
Code: [Select]
/ Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   // Work out where we currently are.
   $current_action = 'home';
   if (in_array($context['current_action'], array('gallery', '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')))
      $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 '
   <div id="styletwo">
   <ul>

';
      // Show the [home] button.
         echo '<li><a' , $current_action=='home' ? ' class="current"' : '' , ' href="', $scripturl, '"><span>' , $txt[103] , '</span></a></li>';

      // Show the [help] button.
          echo '<li><a' , $current_action=='help' ? ' class="current"' : '' , ' href="', $scripturl, '?action=help"><span>' , $txt[119] , '</span></a></li>';

      // How about the [search] button?
      if ($context['allow_search'])
         echo '<li><a' , $current_action=='search' ? ' class="current"' : '' , ' href="', $scripturl, '?action=search"><span>' , $txt[182] , '</span></a></li>';

      // The [calendar]!
      if ($context['allow_calendar'])
         echo '<li><a' , $current_action=='calendar' ? ' class="current"' : '' , ' href="', $scripturl, '?action=calendar"><span>' , $txt['calendar24'] , '</span></a></li>';

      // Is the user allowed to administrate at all? ([admin])
      if ($context['allow_admin'])
         echo '<li><a' , $current_action=='admin' ? ' class="current"' : '' , ' href="', $scripturl, '?action=admin"><span>' , $txt[2] , '</span></a></li>';

      // Edit Profile... [profile]
      if ($context['allow_edit_profile'])
         echo '<li><a' , $current_action=='profile' ? ' class="current"' : '' , ' href="', $scripturl, '?action=profile"><span>' , $txt[79] , '</span></a></li>';

      // Go to PM center... [pm]
   if ($context['user']['is_logged'] && $context['allow_pm'])
      echo '<li><a href="', $scripturl, '?action=pm"><span>' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</span></a></li>';

      // the [member] list button
      if ($context['allow_memberlist'])
         echo '<li><a ' , $current_action=='mlist' ? ' class="current"' : '' , ' href="', $scripturl, '?action=mlist"><span>' , $txt[331] , '</span></a></li>';

     // the [SMF Gallery] button
   if ($context['allow_smfgallery_view'])
      echo ($current_action == 'gallery' || $context['browser']['is_ie4']) ? '<li class="maintab_active_' . $first . '">&nbsp;</li>' : '' , '
            <li valign="top" class="maintab_' , $current_action == 'gallery' ? 'active_back' : 'back' , '">
               <a href="', $scripturl, '?action=gallery">' , $txt['smfgallery_menu']  , '</a>
            </li>' , $current_action == 'gallery' ? '<li class="maintab_active_' . $last . '">&nbsp;</li>' : '';

      // If the user is a guest, show [login] button.
      if ($context['user']['is_guest'])
         echo '<li><a ' , $current_action=='login' ? ' class="current"' : '' , ' href="', $scripturl, '?action=login"><span>' , $txt[34] , '</span></a></li>';

      // If the user is a guest, also show [register] button.
      if ($context['user']['is_guest'])
         echo '<li><a ' , $current_action=='register' ? ' class="current"' : '' , ' href="', $scripturl, '?action=register"><span>' , $txt[97] , '</span></a></li>';

        // the [chat] button
   $chatPath = str_replace("index.php", "chat/index.php", $scripturl);
   $num = (empty($modSettings['enableChatButtonNo'])) ? 0 : count(chatOnlineUsers());
   echo $context['browser']['is_ie4'] ? '<li class="maintab_active_' . $first . '">&nbsp;</li>' : '', '
      <li valign="top" class="maintab_back">
         <a href="', $chatPath, '"', empty($modSettings['chatPopUp']) ? 'target="_blank"' : ' onclick="openWindow(this.href);this.blur();return false;"', '>', $txt['chat'], ($num > 0) ?  ('('.$num.')') : '' , '</a>
      </li>';
     
      // Otherwise, they might want to [logout]...
      if ($context['user']['is_logged'])
         echo '<li><a ' , $current_action=='logout' ? ' class="current"' : '' , 'href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '"><span>' , $txt[108] , '</span></a></li>';

   echo '
      </ul>
</div>';

}

Using the table code for the two menu links only makes them worse then before. So I used the list <li>
code instead. But then ended up with what you see on the screenshot.

I'm not very advanced with php. So go easy on me. I also wasn't sure where this post should go, so I apologize in advance if it is the wrong spot.

Thanks to anyone who can help me resolve this. :)




Offline mashby

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 8,394
  • Gender: Male
  • badass beer hound
    • Choppix
Re: Issue with navigational menu and custom theme.
« Reply #1 on: July 21, 2009, 05:44:24 PM »
You had the right idea for sure!
Code: [Select]
// Show the menu up top. Something like [home] [help] [profile] [logout]...
function template_menu()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   // 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('gallery', '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';

   // 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 '
   <div id="styletwo">
   <ul>

';
      // Show the [home] button.
         echo '<li><a' , $current_action=='home' ? ' class="current"' : '' , ' href="', $scripturl, '"><span>' , $txt[103] , '</span></a></li>';

      // Show the [help] button.
          echo '<li><a' , $current_action=='help' ? ' class="current"' : '' , ' href="', $scripturl, '?action=help"><span>' , $txt[119] , '</span></a></li>';

      // How about the [search] button?
      if ($context['allow_search'])
         echo '<li><a' , $current_action=='search' ? ' class="current"' : '' , ' href="', $scripturl, '?action=search"><span>' , $txt[182] , '</span></a></li>';

      // The [calendar]!
      if ($context['allow_calendar'])
         echo '<li><a' , $current_action=='calendar' ? ' class="current"' : '' , ' href="', $scripturl, '?action=calendar"><span>' , $txt['calendar24'] , '</span></a></li>';

      // Is the user allowed to administrate at all? ([admin])
      if ($context['allow_admin'])
         echo '<li><a' , $current_action=='admin' ? ' class="current"' : '' , ' href="', $scripturl, '?action=admin"><span>' , $txt[2] , '</span></a></li>';

      // Edit Profile... [profile]
      if ($context['allow_edit_profile'])
         echo '<li><a' , $current_action=='profile' ? ' class="current"' : '' , ' href="', $scripturl, '?action=profile"><span>' , $txt[79] , '</span></a></li>';

      // Go to PM center... [pm]
   if ($context['user']['is_logged'] && $context['allow_pm'])
      echo '<li><a href="', $scripturl, '?action=pm"><span>' , $txt['pm_short'] , ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</span></a></li>';

      // the [member] list button
      if ($context['allow_memberlist'])
         echo '<li><a ' , $current_action=='mlist' ? ' class="current"' : '' , ' href="', $scripturl, '?action=mlist"><span>' , $txt[331] , '</span></a></li>';

     // the [SMF Gallery] button
   if ($context['allow_smfgallery_view'])
         echo '<li><a ' , $current_action=='gallery' ? ' class="current"' : '' , ' href="', $scripturl, '?action=gallery"><span>' , $txt['smfgallery_menu']  , '</span></a></li>';

      // If the user is a guest, show [login] button.
      if ($context['user']['is_guest'])
         echo '<li><a ' , $current_action=='login' ? ' class="current"' : '' , ' href="', $scripturl, '?action=login"><span>' , $txt[34] , '</span></a></li>';

      // If the user is a guest, also show [register] button.
      if ($context['user']['is_guest'])
         echo '<li><a ' , $current_action=='register' ? ' class="current"' : '' , ' href="', $scripturl, '?action=register"><span>' , $txt[97] , '</span></a></li>';

        // the [chat] button
   $chatPath = str_replace("index.php", "chat/index.php", $scripturl);
   $num = (empty($modSettings['enableChatButtonNo'])) ? 0 : count(chatOnlineUsers());
    echo '<li><a href="', $chatPath, '"', empty($modSettings['chatPopUp']) ? 'target="_blank"' : ' onclick="openWindow(this.href);this.blur();return false;"', '><span>', $txt['chat'], ($num > 0) ?  ('('.$num.')') : '' , '</span></a></li>';
     
      // Otherwise, they might want to [logout]...
      if ($context['user']['is_logged'])
         echo '<li><a ' , $current_action=='logout' ? ' class="current"' : '' , 'href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '"><span>' , $txt[108] , '</span></a></li>';

   echo '
      </ul>
</div>';

}

I moved the gallery bit to the regular current_action area. When copying code from one theme to another for menu items, it's OK to copy exactly what the default theme does, but when pasted into the custom theme, you have to mimic the code for a tab in the custom theme. Try the above...let us know how it works out (careful of line one...should start with //, your initial code only had one).
Always be a little kinder than necessary.
- James M. Barrie

Offline LC

  • Full Member
  • ***
  • Posts: 508
  • Gender: Female
  • Chaos is the score upon which reality is written.
Re: Issue with navigational menu and custom theme.
« Reply #2 on: July 21, 2009, 09:51:30 PM »
Thanks for pointing out the first line, it was missed when I copy pasted. Chrome does that from time to time. Blah.

But as far as the code, it moved them in line perfectly! Thanks so much. :)