collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 350
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Installation errors? Mod incompatibilities? Upgrade problems? Make your way over to the Install and Upgrade Support board for all your solutions!

Author Topic: Page won't highlight the correct tab.  (Read 10269 times)

0 Members and 1 Guest are viewing this topic.

Offline yangtastic

  • Semi Newbie
  • *
  • Posts: 13
  • SMF Version: 1.1.11
  • SP Version: 2.3.2
Page won't highlight the correct tab.
« on: June 03, 2010, 09:37:04 PM »
Hey SP members,

I use SP to add pages to the site.

I can create a new tab and I can link it to the correct tabs but once the page loads up, the tab that is still highlighted is the tab for index.

This is my code at the moment

Action
Code: [Select]
   if (!empty($_REQUEST['test']) && in_array($_REQUEST['test'], array('page3102', 'test')))
      $current_action = $_REQUEST['test'];

Tab
Code: [Select]
            // Show the [test] button.
            echo '<li><a' , $current_action=='page3102' ? ' class="current"' : '' , ' href="', $scripturl, '?page=page3102"><span>Test</span></a></li>';

How can I modify the code so that the page highlights the correct tab when it is selected?

Thanks.

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Page won't highlight the correct tab.
« Reply #1 on: June 03, 2010, 09:54:58 PM »
Your code repeats the same errors that I fixed in this post: http://simpleportal.net/index.php?topic=5656.msg33921#msg33921

"$_REQUEST['test']" is a variable that never exists, you need to use "$_REQUEST['page']" (where 'page' is NOT your pages id). You also don't need to have 'test' in the "array('page3102', 'test')" as its not your pages id.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline yangtastic

  • Semi Newbie
  • *
  • Posts: 13
  • SMF Version: 1.1.11
  • SP Version: 2.3.2
Re: Page won't highlight the correct tab.
« Reply #2 on: June 03, 2010, 10:21:06 PM »
I applied the changes but it hasn't altered the site at all.

The Portal tab and the Test tab still is highlighting the Forum tab.

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Page won't highlight the correct tab.
« Reply #3 on: June 03, 2010, 10:32:57 PM »
Could you please attach your index.template.php file?
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline yoghurtfarmer

  • Newbie
  • Posts: 2
    • Vancouver Forum
  • SMF Version: None
  • SP Version: None
Re: Page won't highlight the correct tab.
« Reply #4 on: June 03, 2010, 10:39:13 PM »
Hi,

How would you do this for SMF 2.0?  Eg: I have added a Metro Vancouver News tab, but it doesn't get highlighted.
http://www.forumvancouver.com

Also, is there a way to disable certain blocks on the custom pages?

Thank you!

Offline yangtastic

  • Semi Newbie
  • *
  • Posts: 13
  • SMF Version: 1.1.11
  • SP Version: 2.3.2
Re: Page won't highlight the correct tab.
« Reply #5 on: June 04, 2010, 12:00:51 AM »
Here's my index.template.php
Code: [Select]
<?php
// Version: 1.1; index

/*   This template is, perhaps, the most important template in the theme. It
   contains the main template layer that displays the header and footer of
   the forum, namely with main_above and main_below. It also contains the
   menu sub template, which appropriately displays the menu; the init sub
   template, which is there to set the theme up; (init can be missing.) and
   the linktree sub template, which sorts out the link tree.

   The init sub template should load any data and set any hardcoded options.

   The main_above sub template is what is shown above the main content, and
   should contain anything that should be shown up there.

   The main_below sub template, conversely, is shown after the main content.
   It should probably contain the copyright statement and some other things.

   The linktree sub template should display the link tree, using the data
   in the $context['linktree'] variable.

   The menu sub template should display all the relevant buttons the user
   wants and or needs.

   For more information on the templating system, please see the site at:
   http://www.simplemachines.org/
*/
// Initialize the template... mainly little settings.
function template_init()
{
   global 
$context$settings$options$txt;

   
/* Use images from default theme when using templates from the default theme?
      if this is 'always', images from the default theme will be used.
      if this is 'defaults', images from the default theme will only be used with default templates.
      if this is 'never' or isn't set at all, images from the default theme will not be used. */
   
$settings['use_default_images'] = 'never';

   
/* What document type definition is being used? (for font size and other issues.)
      'xhtml' for an XHTML 1.0 document type definition.
      'html' for an HTML 4.01 document type definition. */
   
$settings['doctype'] = 'xhtml';

   
/* The version this template/theme is for.
      This should probably be the version of SMF it was created for. */
   
$settings['theme_version'] = '1.1';

   
/* Set a setting that tells the theme that it can render the tabs. */
   
$settings['use_tabs'] = true;

   
/* Use plain buttons - as oppossed to text buttons? */
   
$settings['use_buttons'] = true;

   
/* Show sticky and lock status seperate from topic icons? */
   
$settings['seperate_sticky_lock'] = true;
}
// The main sub template above the content.
function template_main_above()
{
   global 
$context$settings$options$scripturl$txt$modSettings$boardurl;

   
// Show right to left and the character set for ease of translating.
   
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"'
$context['right_to_left'] ? ' dir="rtl"' '''><head>
   <meta http-equiv="Content-Type" content="text/html; charset='
$context['character_set'], '" />
   <meta name="description" content="'
$context['page_title'], '" />', empty($context['robot_no_index']) ? '' '
   <meta name="robots" content="noindex" />'
'
   <meta name="keywords" content="PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum" />
   <script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/script.js?fin11"></script>
   <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
      var smf_theme_url = "'
$settings['theme_url'], '";
      var smf_images_url = "'
$settings['images_url'], '";
      var smf_scripturl = "'
$scripturl'";
      var smf_iso_case_folding = '
$context['server']['iso_case_folding'] ? 'true' 'false'';
      var smf_charset = "'
$context['character_set'], '";
   // ]]></script>
   <title>'
$context['page_title'], '</title>';

   
// The ?fin11 part of this link is just here to make sure browsers don't cache it wrongly.
   
echo '
   <link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/style.css?fin11" />
   <link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/print.css?fin11" media="print" />';

   
/* Internet Explorer 4/5 and Opera 6 just don't do font sizes properly. (they are big...)
      Thus, in Internet Explorer 4, 5, and Opera 6 this will show fonts one size smaller than usual.
      Note that this is affected by whether IE 6 is in standards compliance mode.. if not, it will also be big.
      Standards compliance mode happens when you use xhtml... */
   
if ($context['browser']['needs_size_fix'])
      echo 
'
   <link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/fonts-compat.css" />';

   
// Show all the relative links, such as help, search, contents, and the like.
   
echo '
   <link rel="help" href="'
$scripturl'?action=help" target="_blank" />
   <link rel="search" href="' 
$scripturl '?action=search" />
   <link rel="contents" href="'
$scripturl'" />';

   
// If RSS feeds are enabled, advertise the presence of one.
   
if (!empty($modSettings['xmlnews_enable']))
      echo 
'
   <link rel="alternate" type="application/rss+xml" title="'
$context['forum_name'], ' - RSS" href="'$scripturl'?type=rss;action=.xml" />';

   
// If we're viewing a topic, these should be the previous and next topics, respectively.
   
if (!empty($context['current_topic']))
      echo 
'
   <link rel="prev" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=prev" />
   <link rel="next" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=next" />';

   
// If we're in a board, or a topic for that matter, the index will be the board's index.
   
if (!empty($context['current_board']))
      echo 
'
   <link rel="index" href="' 
$scripturl '?board=' $context['current_board'] . '.0" />';


   
// We'll have to use the cookie to remember the header...
   
if ($context['user']['is_guest'])
      
$options['collapse_header'] = !empty($_COOKIE['upshrink']);

   
// Output any remaining HTML headers. (from mods, maybe?)
   
echo $context['html_headers'], '
   <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
      var current_header = '
, empty($options['collapse_header']) ? 'false' 'true'';

      function shrinkHeader(mode)
      {'
;

   
// Guests don't have theme options!!
   
if ($context['user']['is_guest'])
      echo 
'
         document.cookie = "upshrink=" + (mode ? 1 : 0);'
;
   else
      echo 
'
         smf_setThemeOption("collapse_header", mode ? 1 : 0, null, "'
$context['session_id'], '");';

   echo 
'
         document.getElementById("upshrink").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");

         document.getElementById("upshrinkHeader").style.display = mode ? "none" : "";

         current_header = mode;
      }
   // ]]></script>'
;

   
// the routine for the info center upshrink
   
echo '
      <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
         var current_header_ic = '
, empty($options['collapse_header_ic']) ? 'false' 'true'';

         function shrinkHeaderIC(mode)
         {'
;

   if (
$context['user']['is_guest'])
      echo 
'
            document.cookie = "upshrinkIC=" + (mode ? 1 : 0);'
;
   else
      echo 
'
            smf_setThemeOption("collapse_header_ic", mode ? 1 : 0, null, "'
$context['session_id'], '");';

   echo 
'
            document.getElementById("upshrink_ic").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");

            document.getElementById("upshrinkHeaderIC").style.display = mode ? "none" : "";

            current_header_ic = mode;
         }
      // ]]></script>'
;

   echo 
'
</head>
<body>
<div id="body-top">
   <div id="container">
      <div id="header">
         <div id="headerleft">
            <div id="headerright">
               <div id="menubar">
                  '
,template_menu(),'
               </div>
               <div id="welcome">'
;
                  if (
$context['user']['is_logged'])
                  {
                  echo 
'
                     <b>'
$txt['hello_member_ndt'], ' '$context['user']['name'], '</b><br />';

                     
// Only tell them about their messages if they can read their messages!
                     
if ($context['allow_pm'])
                     echo 
$txt[152], ' <a href="'$scripturl'?action=pm">'$context['user']['messages'], ' '$context['user']['messages'] != $txt[153] : $txt[471], '</a>'$txt['newmessages4'], ' '$context['user']['unread_messages'], ' '$context['user']['unread_messages'] == $txt['newmessages0'] : $txt['newmessages1'] , '.<br />';

                     echo 
'
                        <a href="'
$scripturl'?action=unread">'$txt['unread_since_visit'], '</a><br />
                        <a href="'
$scripturl'?action=unreadreplies">'$txt['show_unread_replies'], '</a><br />';
                  }

                  
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
                  
else
                  {
                  echo 
'
                     '
$txt['welcome_guest'], '
                     <script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/sha1.js"></script>
                        <form action="'
$scripturl'?action=login2" method="post" accept-charset="'$context['character_set'], '" style="margin: 4px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' $context['session_id'] . '\');"' '''>
                           <input type="text" name="user" size="10" />
                           <input type="password" name="passwrd" size="10" />
                           <input type="submit" value="'
$txt[34], '" />
                           <input type="hidden" name="hash_passwrd" value="" />
                        </form>'
$txt['smf52'], '<br /><br />';
                  }
            echo 
'
               </div>
               <a href="'
.$scripturl.'" title=""><span id="logo"> </span></a>';
         echo 
'
            </div>
         </div>
      </div>
      <div id="mainarea">'
;
      
}
function 
template_main_below()
{
   global 
$context$settings$options$scripturl$txt$user_info;

   echo 
'
      </div>
      <div id="footer">
         <div id="footer-left">
            <div id="footer-right">
               <br />'
theme_copyright(), '<br />Theme by <a href="http://www.dzinerstudio.com"><b>DzinerStudio</b></a>';

               
// Show the load time?
               
if ($context['show_load_time'])
               echo 
'<br />'$txt['smf301'], $context['load_time'], $txt['smf302'], $context['load_queries'], $txt['smf302b'];

         echo 
'
            </div>
         </div>
      </div>
   </div>
</div>'
;
      
echo 
'
</body></html>'
;
}
// Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree()
{
   global 
$context$settings$options;

   echo 
'<div class="nav" style="font-size: smaller; margin-bottom: 2ex; margin-top: 2ex;">';

   
// Each tree item has a URL and name. Some may have extra_before and extra_after.
   
foreach ($context['linktree'] as $link_num => $tree)
   {
      
// Show something before the link?
      
if (isset($tree['extra_before']))
         echo 
$tree['extra_before'];

      
// Show the link, including a URL if it should have one.
      
echo '<b>'$settings['linktree_link'] && isset($tree['url']) ? '<a href="' $tree['url'] . '" class="nav">' $tree['name'] . '</a>' $tree['name'], '</b>';

      
// Show something after the link...?
      
if (isset($tree['extra_after']))
         echo 
$tree['extra_after'];

      
// Don't show a separator for the last one.
      
if ($link_num != count($context['linktree']) - 1)
         echo 
' > ';
   }

   echo 
'</div>';
}
// 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 'forum';
   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')))
      
$current_action $context['current_action'];
   if (
$context['current_action'] == 'search2')
      
$current_action 'search';

   if (!empty(
$_REQUEST['page']) && in_array($_REQUEST['test'], array('page3102')))
      
$current_action $_REQUEST['page']; 

   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="topmenu">
         <ul>'
;

            
// Show the [portal] button.
            
echo '<li><a' $current_action=='portal'' class="current"' '' ' href="'$scripturl'"><span>' $txt[portal] = 'Portal''</span></a></li>';

            
// Show the [forum] button.
            
echo '<li><a' $current_action=='forum' ' class="current"' '' ' href="index.php?action=forum"'$scripturl'"><span>' $txt[forum] = 'Forum' '</span></a></li>';

            
// Show the [test] button.
            
echo '<li><a' $current_action=='page' ' class="current"' '' ' href="'$scripturl'?page=page3102"><span>Test</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' $current_action=='pm' ' class="current"' '' ' href="'$scripturl'?action=pm"><span>' $txt['pm_short'] , ' '$context['user']['unread_messages'] > '[<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>';

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

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


}
// Generate a strip of buttons.
function template_button_strip($button_strip$direction 'top'$force_reset false$custom_td '')
{
   global 
$settings$buttons$context$txt$scripturl;

   
// Create the buttons...
   
foreach ($button_strip as $key => $value)
   {
      if (isset(
$value['test']) && empty($context[$value['test']]))
      {
         unset(
$button_strip[$key]);
         continue;
      }
      elseif (!isset(
$buttons[$key]) || $force_reset)
         
$buttons[$key] = '<a href="' $value['url'] . '" ' .( isset($value['custom']) ? $value['custom'] : '') . '>' $txt[$value['text']] . '</a>';

      
$button_strip[$key] = $buttons[$key];
   }

   if (empty(
$button_strip))
      return 
'<td> </td>';

   echo 
'
      <td class="'
$direction == 'top' 'main' 'mirror''tab_' $context['right_to_left'] ? 'last' 'first' '"> </td>
      <td class="'
$direction == 'top' 'main' 'mirror''tab_back">'implode('  |  '$button_strip) , '</td>
      <td class="'
$direction == 'top' 'main' 'mirror''tab_' $context['right_to_left'] ? 'first' 'last' '"> </td>';
}
?>

yoghurtfarmer, I am basically in the same situation as you.

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Page won't highlight the correct tab.
« Reply #6 on: June 04, 2010, 02:51:40 AM »
yangtastic, try this code:

Code: [Select]
<?php
// Version: 1.1; index

/*   This template is, perhaps, the most important template in the theme. It
   contains the main template layer that displays the header and footer of
   the forum, namely with main_above and main_below. It also contains the
   menu sub template, which appropriately displays the menu; the init sub
   template, which is there to set the theme up; (init can be missing.) and
   the linktree sub template, which sorts out the link tree.

   The init sub template should load any data and set any hardcoded options.

   The main_above sub template is what is shown above the main content, and
   should contain anything that should be shown up there.

   The main_below sub template, conversely, is shown after the main content.
   It should probably contain the copyright statement and some other things.

   The linktree sub template should display the link tree, using the data
   in the $context['linktree'] variable.

   The menu sub template should display all the relevant buttons the user
   wants and or needs.

   For more information on the templating system, please see the site at:
   http://www.simplemachines.org/
*/
// Initialize the template... mainly little settings.
function template_init()
{
   global 
$context$settings$options$txt;

   
/* Use images from default theme when using templates from the default theme?
      if this is 'always', images from the default theme will be used.
      if this is 'defaults', images from the default theme will only be used with default templates.
      if this is 'never' or isn't set at all, images from the default theme will not be used. */
   
$settings['use_default_images'] = 'never';

   
/* What document type definition is being used? (for font size and other issues.)
      'xhtml' for an XHTML 1.0 document type definition.
      'html' for an HTML 4.01 document type definition. */
   
$settings['doctype'] = 'xhtml';

   
/* The version this template/theme is for.
      This should probably be the version of SMF it was created for. */
   
$settings['theme_version'] = '1.1';

   
/* Set a setting that tells the theme that it can render the tabs. */
   
$settings['use_tabs'] = true;

   
/* Use plain buttons - as oppossed to text buttons? */
   
$settings['use_buttons'] = true;

   
/* Show sticky and lock status seperate from topic icons? */
   
$settings['seperate_sticky_lock'] = true;
}
// The main sub template above the content.
function template_main_above()
{
   global 
$context$settings$options$scripturl$txt$modSettings$boardurl;

   
// Show right to left and the character set for ease of translating.
   
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"'
$context['right_to_left'] ? ' dir="rtl"' '''><head>
   <meta http-equiv="Content-Type" content="text/html; charset='
$context['character_set'], '" />
   <meta name="description" content="'
$context['page_title'], '" />', empty($context['robot_no_index']) ? '' '
   <meta name="robots" content="noindex" />'
'
   <meta name="keywords" content="PHP, MySQL, bulletin, board, free, open, source, smf, simple, machines, forum" />
   <script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/script.js?fin11"></script>
   <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
      var smf_theme_url = "'
$settings['theme_url'], '";
      var smf_images_url = "'
$settings['images_url'], '";
      var smf_scripturl = "'
$scripturl'";
      var smf_iso_case_folding = '
$context['server']['iso_case_folding'] ? 'true' 'false'';
      var smf_charset = "'
$context['character_set'], '";
   // ]]></script>
   <title>'
$context['page_title'], '</title>';

   
// The ?fin11 part of this link is just here to make sure browsers don't cache it wrongly.
   
echo '
   <link rel="stylesheet" type="text/css" href="'
$settings['theme_url'], '/style.css?fin11" />
   <link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/print.css?fin11" media="print" />';

   
/* Internet Explorer 4/5 and Opera 6 just don't do font sizes properly. (they are big...)
      Thus, in Internet Explorer 4, 5, and Opera 6 this will show fonts one size smaller than usual.
      Note that this is affected by whether IE 6 is in standards compliance mode.. if not, it will also be big.
      Standards compliance mode happens when you use xhtml... */
   
if ($context['browser']['needs_size_fix'])
      echo 
'
   <link rel="stylesheet" type="text/css" href="'
$settings['default_theme_url'], '/fonts-compat.css" />';

   
// Show all the relative links, such as help, search, contents, and the like.
   
echo '
   <link rel="help" href="'
$scripturl'?action=help" target="_blank" />
   <link rel="search" href="' 
$scripturl '?action=search" />
   <link rel="contents" href="'
$scripturl'" />';

   
// If RSS feeds are enabled, advertise the presence of one.
   
if (!empty($modSettings['xmlnews_enable']))
      echo 
'
   <link rel="alternate" type="application/rss+xml" title="'
$context['forum_name'], ' - RSS" href="'$scripturl'?type=rss;action=.xml" />';

   
// If we're viewing a topic, these should be the previous and next topics, respectively.
   
if (!empty($context['current_topic']))
      echo 
'
   <link rel="prev" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=prev" />
   <link rel="next" href="'
$scripturl'?topic='$context['current_topic'], '.0;prev_next=next" />';

   
// If we're in a board, or a topic for that matter, the index will be the board's index.
   
if (!empty($context['current_board']))
      echo 
'
   <link rel="index" href="' 
$scripturl '?board=' $context['current_board'] . '.0" />';


   
// We'll have to use the cookie to remember the header...
   
if ($context['user']['is_guest'])
      
$options['collapse_header'] = !empty($_COOKIE['upshrink']);

   
// Output any remaining HTML headers. (from mods, maybe?)
   
echo $context['html_headers'], '
   <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
      var current_header = '
, empty($options['collapse_header']) ? 'false' 'true'';

      function shrinkHeader(mode)
      {'
;

   
// Guests don't have theme options!!
   
if ($context['user']['is_guest'])
      echo 
'
         document.cookie = "upshrink=" + (mode ? 1 : 0);'
;
   else
      echo 
'
         smf_setThemeOption("collapse_header", mode ? 1 : 0, null, "'
$context['session_id'], '");';

   echo 
'
         document.getElementById("upshrink").src = smf_images_url + (mode ? "/upshrink2.gif" : "/upshrink.gif");

         document.getElementById("upshrinkHeader").style.display = mode ? "none" : "";

         current_header = mode;
      }
   // ]]></script>'
;

   
// the routine for the info center upshrink
   
echo '
      <script language="JavaScript" type="text/javascript"><!-- // --><![CDATA[
         var current_header_ic = '
, empty($options['collapse_header_ic']) ? 'false' 'true'';

         function shrinkHeaderIC(mode)
         {'
;

   if (
$context['user']['is_guest'])
      echo 
'
            document.cookie = "upshrinkIC=" + (mode ? 1 : 0);'
;
   else
      echo 
'
            smf_setThemeOption("collapse_header_ic", mode ? 1 : 0, null, "'
$context['session_id'], '");';

   echo 
'
            document.getElementById("upshrink_ic").src = smf_images_url + (mode ? "/expand.gif" : "/collapse.gif");

            document.getElementById("upshrinkHeaderIC").style.display = mode ? "none" : "";

            current_header_ic = mode;
         }
      // ]]></script>'
;

   echo 
'
</head>
<body>
<div id="body-top">
   <div id="container">
      <div id="header">
         <div id="headerleft">
            <div id="headerright">
               <div id="menubar">
                  '
,template_menu(),'
               </div>
               <div id="welcome">'
;
                  if (
$context['user']['is_logged'])
                  {
                  echo 
'
                     <b>'
$txt['hello_member_ndt'], ' '$context['user']['name'], '</b><br />';

                     
// Only tell them about their messages if they can read their messages!
                     
if ($context['allow_pm'])
                     echo 
$txt[152], ' <a href="'$scripturl'?action=pm">'$context['user']['messages'], ' '$context['user']['messages'] != $txt[153] : $txt[471], '</a>'$txt['newmessages4'], ' '$context['user']['unread_messages'], ' '$context['user']['unread_messages'] == $txt['newmessages0'] : $txt['newmessages1'] , '.<br />';

                     echo 
'
                        <a href="'
$scripturl'?action=unread">'$txt['unread_since_visit'], '</a><br />
                        <a href="'
$scripturl'?action=unreadreplies">'$txt['show_unread_replies'], '</a><br />';
                  }

                  
// Otherwise they're a guest - this time ask them to either register or login - lazy bums...
                  
else
                  {
                  echo 
'
                     '
$txt['welcome_guest'], '
                     <script language="JavaScript" type="text/javascript" src="'
$settings['default_theme_url'], '/sha1.js"></script>
                        <form action="'
$scripturl'?action=login2" method="post" accept-charset="'$context['character_set'], '" style="margin: 4px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' $context['session_id'] . '\');"' '''>
                           <input type="text" name="user" size="10" />
                           <input type="password" name="passwrd" size="10" />
                           <input type="submit" value="'
$txt[34], '" />
                           <input type="hidden" name="hash_passwrd" value="" />
                        </form>'
$txt['smf52'], '<br /><br />';
                  }
            echo 
'
               </div>
               <a href="'
.$scripturl.'" title=""><span id="logo"> </span></a>';
         echo 
'
            </div>
         </div>
      </div>
      <div id="mainarea">'
;
      
}
function 
template_main_below()
{
   global 
$context$settings$options$scripturl$txt$user_info;

   echo 
'
      </div>
      <div id="footer">
         <div id="footer-left">
            <div id="footer-right">
               <br />'
theme_copyright(), '<br />Theme by <a href="http://www.dzinerstudio.com"><b>DzinerStudio</b></a>';

               
// Show the load time?
               
if ($context['show_load_time'])
               echo 
'<br />'$txt['smf301'], $context['load_time'], $txt['smf302'], $context['load_queries'], $txt['smf302b'];

         echo 
'
            </div>
         </div>
      </div>
   </div>
</div>'
;
      
echo 
'
</body></html>'
;
}
// Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree()
{
   global 
$context$settings$options;

   echo 
'<div class="nav" style="font-size: smaller; margin-bottom: 2ex; margin-top: 2ex;">';

   
// Each tree item has a URL and name. Some may have extra_before and extra_after.
   
foreach ($context['linktree'] as $link_num => $tree)
   {
      
// Show something before the link?
      
if (isset($tree['extra_before']))
         echo 
$tree['extra_before'];

      
// Show the link, including a URL if it should have one.
      
echo '<b>'$settings['linktree_link'] && isset($tree['url']) ? '<a href="' $tree['url'] . '" class="nav">' $tree['name'] . '</a>' $tree['name'], '</b>';

      
// Show something after the link...?
      
if (isset($tree['extra_after']))
         echo 
$tree['extra_after'];

      
// Don't show a separator for the last one.
      
if ($link_num != count($context['linktree']) - 1)
         echo 
' > ';
   }

   echo 
'</div>';
}
// 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 'forum';
   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')))
      
$current_action $context['current_action'];
   if (
$context['current_action'] == 'search2')
      
$current_action 'search';

   if (!empty(
$_REQUEST['page']) && in_array($_REQUEST['page'], array('page3102')))
      
$current_action $_REQUEST['page']; 

   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="topmenu">
         <ul>'
;

            
// Show the [portal] button.
            
echo '<li><a' $current_action=='portal'' class="current"' '' ' href="'$scripturl'"><span>' $txt[portal] = 'Portal''</span></a></li>';

            
// Show the [forum] button.
            
echo '<li><a' $current_action=='forum' ' class="current"' '' ' href="index.php?action=forum"'$scripturl'"><span>' $txt[forum] = 'Forum' '</span></a></li>';

            
// Show the [test] button.
            
echo '<li><a' $current_action=='page3102' ' class="current"' '' ' href="'$scripturl'?page=page3102"><span>Test</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' $current_action=='pm' ' class="current"' '' ' href="'$scripturl'?action=pm"><span>' $txt['pm_short'] , ' '$context['user']['unread_messages'] > '[<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>';

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

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


}
// Generate a strip of buttons.
function template_button_strip($button_strip$direction 'top'$force_reset false$custom_td '')
{
   global 
$settings$buttons$context$txt$scripturl;

   
// Create the buttons...
   
foreach ($button_strip as $key => $value)
   {
      if (isset(
$value['test']) && empty($context[$value['test']]))
      {
         unset(
$button_strip[$key]);
         continue;
      }
      elseif (!isset(
$buttons[$key]) || $force_reset)
         
$buttons[$key] = '<a href="' $value['url'] . '" ' .( isset($value['custom']) ? $value['custom'] : '') . '>' $txt[$value['text']] . '</a>';

      
$button_strip[$key] = $buttons[$key];
   }

   if (empty(
$button_strip))
      return 
'<td> </td>';

   echo 
'
      <td class="'
$direction == 'top' 'main' 'mirror''tab_' $context['right_to_left'] ? 'last' 'first' '"> </td>
      <td class="'
$direction == 'top' 'main' 'mirror''tab_back">'implode('  |  '$button_strip) , '</td>
      <td class="'
$direction == 'top' 'main' 'mirror''tab_' $context['right_to_left'] ? 'first' 'last' '"> </td>';
}
?>
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Page won't highlight the correct tab.
« Reply #7 on: June 04, 2010, 02:58:08 AM »
THIS POST ONLY APPLIES TO SMF 2!

Hi,

How would you do this for SMF 2.0?  Eg: I have added a Metro Vancouver News tab, but it doesn't get highlighted.
http://www.forumvancouver.com

Also, is there a way to disable certain blocks on the custom pages?

Thank you!

The edit is a bit different for SMF 2.

Code: ("Find (Subs.php)") [Select]
if (isset($context['menu_buttons'][$context['current_action']]))
$current_action = $context['current_action'];

Code: ("Replace") [Select]
if (isset($context['menu_buttons'][$context['current_action']]))
$current_action = $context['current_action'];
elseif (!empty($_REQUEST['page']) && in_array($_REQUEST['page'], array('pageid')))
$current_action = $_REQUEST['page'];

That assumes that you have already added the button to the $buttons array (see this tutorial for doing that), and that the array key for your button is the same as the id used in the url (not the title that the page has, nor the text that is displayed on the button tab).
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline yoghurtfarmer

  • Newbie
  • Posts: 2
    • Vancouver Forum
  • SMF Version: None
  • SP Version: None
Re: Page won't highlight the correct tab.
« Reply #8 on: June 04, 2010, 08:02:07 AM »
Worked great!  Had some trouble when I didn't know that "page" was supposed to be left as page.

What is the difference between the code you have here and the one you posted in this thread http://simpleportal.net/index.php?topic=3857.0?

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Page won't highlight the correct tab.
« Reply #9 on: June 04, 2010, 09:50:37 AM »
Worked great!  Had some trouble when I didn't know that "page" was supposed to be left as page.

What is the difference between the code you have here and the one you posted in this thread http://simpleportal.net/index.php?topic=3857.0?

The code in this thread forces you to manually add the page ids into the array within the if statement, while the other one does not. Although for the other code if you have a page with id 'home' or 'forum' then those tabs would be set as current, when viewing those pages. The code in this thread is probably better, if you can be bothered adding each page id into the "array('pageid')" array.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline deansmar

  • Full Member
  • ***
  • Posts: 122
  • Gender: Male
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Page won't highlight the correct tab.
« Reply #10 on: July 01, 2010, 09:28:44 AM »
i have tryed both

Code: [Select]
  elseif (!empty($_REQUEST['page']) && in_array($_REQUEST['page'], array('History', 'pageid2' , 'pageid3' )))
        $current_action = $_REQUEST['page'];

and

Code: [Select]
elseif (empty($context['current_action']) && !empty($_REQUEST['page']) && isset($context['menu_buttons'][$_REQUEST['page']]))     
         $current_action = $_REQUEST['page'];

both codes work very well for the main array, but does not take into account any Sub_Button arrays

would i just have the change the ($context['menu_buttons']
into ($context['sub_buttons']

regards
as a foot note:
i went from a SMF 1.1.11 to SMF2 RC3 with out any problems what so ever, first of all de-install all Mods, converted to RC3, then installed SP2.3.2, then installed the required Mods.

Offline deansmar

  • Full Member
  • ***
  • Posts: 122
  • Gender: Male
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Page won't highlight the correct tab.
« Reply #11 on: July 01, 2010, 11:34:13 AM »
the only way that i have found that works at the moment is this

this is for two Sub_Buttons in an Array, this code has been added to the sources\subs.php some time after this line:

Code: [Select]
// Figure out which action we are doing so we can set the active tab.
of course the Page-ID has to be the ID of your page and like wise the Array-ID is the name of the main Array not the name of the sub arrays

Code: [Select]
  elseif (isset($_REQUEST['page']) && $_REQUEST['page'] == 'Page-ID')
    $current_action = 'Array-ID';
  elseif (isset($_REQUEST['page']) && $_REQUEST['page'] == 'Page-ID')
    $current_action = 'Array-ID';
as a foot note:
i went from a SMF 1.1.11 to SMF2 RC3 with out any problems what so ever, first of all de-install all Mods, converted to RC3, then installed SP2.3.2, then installed the required Mods.

Offline Nathaniel

  • Comrade
  • *
  • Posts: 5203
  • Gender: Male
    • Verbtest.com
  • SMF Version: 2 RC4
  • SP Version: 2.3.3
Re: Page won't highlight the correct tab.
« Reply #12 on: July 02, 2010, 09:48:58 PM »
deansmar,
If you are trying to do what I think you are; have multiple pages highlight a certain tab, then try something like the code below:

Code: [Select]
  elseif (!empty($_REQUEST['page']) && in_array($_REQUEST['page'], array('History', 'pageid2' , 'pageid3' )))
        $current_action = 'Array-ID';

Where 'Array-ID' is the id of the main button array, which contains the subbuttons for each of the pages.
SMF Friend (Former Support Specialist) | SimplePortal DeveloperMy SMF Mods | SimplePortal"Quis custodiet ipsos custodes?" - Who will Guard the Guards?Please don't send me ANY support related PMs. I will just delete them.

Offline deansmar

  • Full Member
  • ***
  • Posts: 122
  • Gender: Male
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Page won't highlight the correct tab.
« Reply #13 on: July 03, 2010, 08:48:35 AM »
problems all solved, the answers are in this post

i was not to sure wether it was a SP or SMF problem.

http://www.simplemachines.org/community/index.php?topic=357796.msg2686903#msg2686903

thanks for your answer, but by the time i had seen it, i had allready fix my problem my self..
as a foot note:
i went from a SMF 1.1.11 to SMF2 RC3 with out any problems what so ever, first of all de-install all Mods, converted to RC3, then installed SP2.3.2, then installed the required Mods.

Offline cowboytns

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 2 RC2
  • SP Version: None
Re: Page won't highlight the correct tab.
« Reply #14 on: July 11, 2010, 11:46:36 PM »
ote]
That assumes that you have already added the button to the $buttons array (see this tutorial for doing that), and that the array key for your button is the same as the id used in the url (not the title that the page has, nor the text that is displayed on the button tab).

okay silly question from a self taught html student.  How do I set the "id used in the url".  Is it a meta tag?

Offline deansmar

  • Full Member
  • ***
  • Posts: 122
  • Gender: Male
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Page won't highlight the correct tab.
« Reply #15 on: July 12, 2010, 06:45:10 AM »
i would imagine your talking about the ID's for a page or Tab.??

  'History' => array(                        //Array ID or Array Key
        'title' => 'Company Info',        //Text Tab or Button
        'href' => $scripturl . '?page=History',  //Page ID in the URL
        'show' => true,
        'sp_page' => true,
        'sub_buttons' => array(
        ),

is this what you were looking for ?? it shows the ID in the URL
as a foot note:
i went from a SMF 1.1.11 to SMF2 RC3 with out any problems what so ever, first of all de-install all Mods, converted to RC3, then installed SP2.3.2, then installed the required Mods.

Offline cowboytns

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 2 RC2
  • SP Version: None
Re: Page won't highlight the correct tab.
« Reply #16 on: July 12, 2010, 09:19:37 AM »
No.  I have my subs.php set up properly.  However, per the quote I extracted from Nathaniel on June 4, I still need to define the "id in the url".  This is for a webpage that is outside of the preset forum pages.   This is the array that I set up in subs.php:

  'brainmush' => array(                        //Array ID or Array Key
        'title' => 'Home',                          //Text Tab or Button
        'href' => 'http://brainmush.net/forum2/home.php'?page=brainmush',  //Page ID in the URL
        'show' => true,
        'sp_page' => true,
        'sub_buttons' => array(
        ),

So now on my webpage (http://brainmush.net/forum2/home.php) how do I define the "page id" so that the functions in subs.php knows that it should highlight the "home" tab?

If it helps, here is my home page code:
Code: [Select]
<?php

// Load up SSI
require(dirname(__FILE__) . '/SSI.php');

// Set up the page title
$context['page_title'] = 'Brainmush.net';
$context['page_title_html_safe'] = 'Brainmush.net';

// Set up linktree
$context['linktree'][] = array(
  
'url' => $_SERVER['PHP_SELF'],
  
);

// Initialize the template
template_init();

// Load up the headers
template_header();

// Load your template function
template_main();

// Load the template footer
template_footer();

// Set up the main template
function template_main()
{
global $context$settings$options$scripturl$txt$modSettings;

echo '

<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="left" class="catbg">Brainmush.net Is Going To Rock!</td></tr>

<tr>
     <td>
         <p align="justify"><b>Welcome to Brainmush.net.  Currently this site is under construction.  However, some of the ideas that we are planning are described here.  Take a look and let us know what you think in the forums.</b></p>
     </td>
</tr>

</table><br>'
;

echo 
'
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="top">
<td width="50%">
<table cellpadding="2" cellspacing="0" border="0" align="top">
<tr>
     <td width="50%" class="catbg">Forum
     </td>
</tr>
<tr>
     <td width="50%">
          <p align="justify">Eventually all of the topics from the old forum will be moved to the new forum.  There are hopes that we will be able to provide topic previews on this webpage on the forum discussions.</p>
     </td>
</tr>
<tr>
     <td width="50%" class="catbg">News
     </td>
</tr>
<tr>
     <td width="50%">
          <p align="justify">The news area gives us a place to combine headlines from several news sources that our contributors prefer.  All contributors are encouraged to let the site administartors know of any news sources that they would like to see on the site.</p>
     </td>
</tr>
<tr>
     <td width="50%" class="catbg">The Reading Room
     </td>
</tr>
<tr>
     <td width="50%">
          <p align="justify">The reading room will have two sections:  book reviews and book discussions.  The book reviews section will contain books reviewed by site contributors and possibly guests.  Hopefully we will be able to figure out how to sort the book reviews by several parameters: author, title, subject, type, etc.  There will be a box at the bottom of the page for others to contribute a book review.  All reviews will not be posted until reviewd by the site administrators.</p>
     </td>
</tr>
</table>
</td>

<td width="8">&nbsp;</td>

<td width="50%" align="top">
<table cellpadding="2" cellspacing="0" border="0" align="top">
<tr>
     <td width="50%" class="catbg">TNA Brewing
     </td>
</tr>
<tr>
     <td width="50%">
          <p align="justify">This area of the site will be a dedication to one of the past times of the site founders, home brewing.  This will be a brief history of all of the brews that they have brewed throughout the history of their "brewery".</p>
     </td>
</tr>
<tr>
     <td width="50%" class="catbg">About Brainmush
     </td>
</tr>
<tr>
     <td width="50%">
          <p align="justify">Here information will be provided on the background for Brainmush.net.  Also there may be a place to briefly introduce the site founders and/or contributors.  This way users of the site may get a better feel for where an author of an article is coming from.</p>
     </td>
</tr>
</table>
</td>
</table>'
;
}



?>
« Last Edit: July 12, 2010, 09:37:46 AM by cowboytns »

Offline deansmar

  • Full Member
  • ***
  • Posts: 122
  • Gender: Male
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Page won't highlight the correct tab.
« Reply #17 on: July 12, 2010, 10:26:48 AM »
in your URL code you have an ' to many after the home.php should come the questionmark, then it should work.

 'href' => 'http://brainmush.net/forum2/home.php?page=brainmush', 
as a foot note:
i went from a SMF 1.1.11 to SMF2 RC3 with out any problems what so ever, first of all de-install all Mods, converted to RC3, then installed SP2.3.2, then installed the required Mods.

Offline cowboytns

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 2 RC2
  • SP Version: None
Re: Page won't highlight the correct tab.
« Reply #18 on: July 12, 2010, 10:50:37 AM »
Thank you for pointing out the mistake, I was typing the code from memory.  I actually had it correct (as you pointed out)in the subs.php file.  Based on what I am reading from Nathaniel's post, my issue is something to do with the external page (my home page), defining it's id...not the subs.php file.  Refer to my previous post for my home page coding.

Offline deansmar

  • Full Member
  • ***
  • Posts: 122
  • Gender: Male
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Page won't highlight the correct tab.
« Reply #19 on: July 12, 2010, 11:01:02 AM »
what is not Highlighting ?? what do you actualy mean by homepage ??

i suppose your going from one website, to a different website ?

when copying your URL into a browser and hit enter the home button of your Brainmush.net site is highlighted correct.

which tab do you want to highlight?

the ID's are noramly all defined in the Subs.php
as a foot note:
i went from a SMF 1.1.11 to SMF2 RC3 with out any problems what so ever, first of all de-install all Mods, converted to RC3, then installed SP2.3.2, then installed the required Mods.

Offline deansmar

  • Full Member
  • ***
  • Posts: 122
  • Gender: Male
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Page won't highlight the correct tab.
« Reply #20 on: July 12, 2010, 11:24:04 AM »
have you also added in the Subs.php after the line:

   // Figure out which action we are doing so we can set the active tab.   // Default to home.

somthing simular to this

  elseif (isset($_REQUEST['page']) && $_REQUEST['page'] == 'Page-ID')       $current_action = 'Array-ID';

were page-ID would be brainmush
were array-ID would be brainmush
as a foot note:
i went from a SMF 1.1.11 to SMF2 RC3 with out any problems what so ever, first of all de-install all Mods, converted to RC3, then installed SP2.3.2, then installed the required Mods.

Offline cowboytns

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 2 RC2
  • SP Version: None
Re: Page won't highlight the correct tab.
« Reply #21 on: July 12, 2010, 11:46:53 AM »
Quote
what is not Highlighting ??
- The home tab when I am on my homepage http://brainmush.net/forum2/home.php

Quote
what do you actualy mean by homepage ??
- my homepage is http://brainmush.net/forum2/home.php in contrast to the forum home which is http://brainmush.net/forum2/index.php

Quote
i suppose your going from one website, to a different website ?
- well sort of...I have pasted my homepage into the forum folders so that I can use the forum theme for my webpage.

Quote
when copying your URL into a browser and hit enter the home button of your Brainmush.net site is highlighted correct.
- no the "forum index" tab remains highlighted.

Quote
which tab do you want to highlight?
- I want the home tab to highlight.

the ID's are noramly all defined in the Subs.php




this is the code for the first menu item in subs.php:
Code: [Select]
$buttons = array(
'brainmush' => array(
'title' => $txt['home'],
'href' => 'http://brainmush.net/forum2/home.php?page=brainmush',
'show' => true,
                                'sp_page' => true,
'sub_buttons' => array(
),
'is_last' => $context['right_to_left'],
// 'target' => '_blank',
),

This is what is written after //Figure our which action we are doing...

Code: [Select]
// Figure out which action we are doing so we can set the active tab.
// Default to home.
$current_action = 'home';

if (isset($context['menu_buttons'][$context['current_action']]) && empty($context['menu_buttons'][$context['current_action']]['sp_page']))
      $current_action = $context['current_action'];
   elseif (empty($context['current_action']) && !empty($_REQUEST['page']) && isset($context['menu_buttons'][$_REQUEST['page']]))
      $current_action = $_REQUEST['page'];
elseif (isset($_REQUEST['page']) && $_REQUEST['page'] == 'Page-ID')       $current_action = 'Array-ID';
elseif ($context['current_action'] == 'search2')
$current_action = 'search';
elseif ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';
elseif ($context['current_action'] == 'register2')
$current_action = 'register';
elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
$current_action = 'login';

$context['menu_buttons'][$current_action]['active_button'] = true;

if (!$user_info['is_guest'] && $context['user']['unread_messages'] > 0 && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' ['. $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>'. $context['user']['unread_messages'] . '</strong>]';
}
}

my hompage coding is on reply number 16

Any ideas?

Thanks
« Last Edit: July 12, 2010, 11:49:16 AM by cowboytns »

Offline deansmar

  • Full Member
  • ***
  • Posts: 122
  • Gender: Male
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Page won't highlight the correct tab.
« Reply #22 on: July 12, 2010, 11:57:25 AM »
yes lots of ideas..

your URL is : http://brainmush.net/forum2/home.php?page=brainmush

and not just :  http://brainmush.net/forum2/home.php

the home tab will only highlight if the page action is called

as i said, if you copy your URL into a browser http://brainmush.net/forum2/home.php?page=brainmush
your home page tab will highlight, which shows the fault lyies in your Subs.php


in your Subs.php you have not changed the Page-ID for branmush and you have not changed the Array-ID for branmush..

the line should look like this:

elseif (isset($_REQUEST['page']) && $_REQUEST['page'] == 'brainmush') //page-id
       $current_action = 'brainmush'; // Array-ID
as a foot note:
i went from a SMF 1.1.11 to SMF2 RC3 with out any problems what so ever, first of all de-install all Mods, converted to RC3, then installed SP2.3.2, then installed the required Mods.

Offline cowboytns

  • Semi Newbie
  • *
  • Posts: 5
  • SMF Version: 2 RC2
  • SP Version: None
Re: Page won't highlight the correct tab.
« Reply #23 on: July 12, 2010, 01:53:52 PM »
Can you tell that it just got a little brighter in the room cause the light bulb just turned on!  I see what you are talking about now.  I misread what Nathaniel was saying, I thought he meant that somewhere in the coding of my homepage I had to define a page id...however, as you have pointed out here the page id is identified in the url itself.  Sorry I'm a little slow at this coding stuff. 

So I will redifine all of my links to load the url: http://brainmush.net/forum2/home/php?page=brainmush.  When I did that the home tab is highlighted when I go to the page.  I have also fixed the subs.php file per your suggestion as well.

Thank you so much for your help.

Offline deansmar

  • Full Member
  • ***
  • Posts: 122
  • Gender: Male
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Page won't highlight the correct tab.
« Reply #24 on: July 12, 2010, 02:06:34 PM »
i am by far no code brain...

its just that i had a simular problem, that i sorted my self with a little bit of reading of other posts.

it just supprises me that you are not using Simple Portal, but yet you have posted here.

all your answers are also ready available on the SMF forum, under this post.
http://www.simplemachines.org/community/index.php?topic=357796

but its nice to see you have understood, how the Subs.php works, hope the light stays on for a while longer.

you might want to change the Array concerning the "News Links" so that tab highlights when selecting one of the Sub arrays, its all explaind in the above link.

as a foot note:
i went from a SMF 1.1.11 to SMF2 RC3 with out any problems what so ever, first of all de-install all Mods, converted to RC3, then installed SP2.3.2, then installed the required Mods.