Uutiset:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu
Advertisement:

Problem with $current_action

Aloittaja Ravyn, syyskuu 19, 2006, 07:07:21 IP

« edellinen - seuraava »

Ravyn

So I've added a few tabs to my menubar.  I'm using the SSI to create a main template for my site, and have edited the 'Home' tab to direct to www.mysite.com/index.php instead of the forums.

I then added a 'Forums' Tab that directs to www.mysite.com/forums/

The only problem, is when they use the 'Forums' tab.. the menubar doesnt display the 'Forums' tab as the Active link, it remains on 'Home'

I tried changing the following code:

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


I changed that to 'tarforum' which worked, and set the Active Tab to the 'Forums' tab.  However, now when they use the 'Home' tab to go back to the mainpage, the Active Tab is still 'Forums' instead of back to 'Home'

Any input would be appreciated.

Edit: site is at www.theadamsreunion.com/index.php
Ravyn
-SMF Newbie in Training

Ravyn

Still having the above problem.. as well as a new one.

I've been formatting the layout for my ssi_BoardNews(); call.  It looks great in firefox, but in IE, the table layout messes up when the body of the news post has a long paragraph without a line break.  The error is displayed in my first listed news post on the main page here: www.theadamsreunion.com/index.php

Note: It looks fine in firefox, please load the page in IE to see the problem.

Any help with either or both issues would be appreciated.
Ravyn
-SMF Newbie in Training

Ravyn

Update: Got the template issue for my BoardNews function working properly.  Still haven't been able to solve the issue regarding the $current_action Active tab.
Ravyn
-SMF Newbie in Training

kegobeer

"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Ravyn

Yea, I read that at length when I first was creating my buttons. 

I've got the buttons added and working just fine.  However I've got a homepage, and I've used SMF's SSI to add the menubar to my mainpage, and edited the home tab in the menubar to point to it.

I then added a tab called "tarforum" that is a link to my forums. However, when I load up my main page at www.theadamsreunion.com/index.php you can see that the "Home" tab is not displaying the "Active" graphics.

You can login with the info Login: test  Pass: test to see the other link.

You will see that the "Forums" tab is active when you're on my homepage, and similar, the "Forums" tab is active when you click on it to view my forums.

I'm trying to figure out how to make it so the "Home" tab becomes active when you are viewing my mainpage.

The code for the home button and the forum button is as follows:

// Show the [home] button.
echo ($current_action=='home' || $context['browser']['is_ie4']) ? '<td class="bordermirrortab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="bordermirrortab_' , $current_action == 'home' ? 'active_back' : 'back' , '">
<a href="http://www.theadamsreunion.com/index.php">' , $txt[103] , '</a>
</td>' , $current_action == 'home' ? '<td class="bordermirrortab_active_' . $last . '">&nbsp;</td>' : '';

// Show the [forums] button.
if ($context['user']['is_logged'])
echo ($current_action=='tarforum' || $context['browser']['is_ie4']) ? '<td class="bordermirrortab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="bordermirrortab_' , $current_action == 'tarforum' ? 'active_back' : 'back' , '">
<a href="http://www.theadamsreunion.com/forums/">Forums</a>
</td>' , $current_action == 'tarforum' ? '<td class="bordermirrortab_active_' . $last . '">&nbsp;</td>' : '';


Thats the code.  Which I don't believe is where the issue lies.  The active tab seems to be controlled solely by this code contained in the index.template.php:


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


I set that to 'tarforum' within the index.template.php of my board so that the Active tab would be "Forums" when viewing my forums.  I'm guessing since I call the menubar function in my main page that it loads that same code, setting the active tab to Forums again, how can I change that variable to display the proper active tab when viewing my mainpage? The relevant code for my mainpage:


    <body>
    <table width="800" cellpadding="0" cellspacing="0" align="center" border="0" class="mainborder">
      <tr width="800" height="155" class="logobg">
        <td valign="bottom" align="right">';
          $current_action = 'home';
          ssi_menubar();
        echo '
        </td>
      </tr>


I tried adding the line $current_action = 'home'; to my mainpage index.php in hopes of fixing that, but it displays the forum tab as active regardless.

Thanks for your time.
Ravyn
-SMF Newbie in Training

Dannii

It would be easiest to rename home to forum, and then add a new home button.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Ravyn

I dont see how that would change anything? It would contain the exact same coding, all I'd essentially be doing is switching 'home' to 'tarforum' for the 2 seperate buttons... I may as well cut/copy/paste the buttons to reverse their order, that won't effect which one is displayed as active?
Ravyn
-SMF Newbie in Training

Ravyn

I switched the $current_action = 'tarforum'; back to 'home'; in the index.template.php.

Which makes it show up properly for the mainpage.  The 'Home' button is active.  However, when you click the forum link, the 'Home' tab remains active, instead of setting the 'Forum' tab to active.  This is the same effect I believe would be obtained by creating a new tab for 'Home' and changing the current home tab to say Forums.
Ravyn
-SMF Newbie in Training

kegobeer

Did you set a custom action for your main page?  For example, on your custom start page, before you make any SSI calls, set $_GET['action'] = 'mymain'.  Then, in index.template.php, you'd do something like this:

After the $current_action = 'home'; statement, you'd add this:


if ($context['current_action'] == 'mymain')
    $current_action = 'mymain';


Then, in the button section, you'd add this:

if ($context['user']['is_logged'])
echo ($current_action=='mymain' || $context['browser']['is_ie4']) ? '<td class="bordermirrortab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="bordermirrortab_' , $current_action == 'mymain' ? 'active_back' : 'back' , '">
<a href="http://www.theadamsreunion.com/forums/">Forums</a>
</td>' , $current_action == 'mymain' ? '<td class="bordermirrortab_active_' . $last . '">&nbsp;</td>' : '';


Now, I just copied and pasted your tarforum code to use it as an example.  I'm sure you know what to actually do.  I would reset your buttons to the default, and then add your custom code.
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

Ravyn

Hey,

Thanks for the help eld and keg.  I didn't do exactly as you suggested with the $_GET call keg, but that idea put me in the proper mindset to see where my error was. 

I just had to include ?action=variable on the end of my url, so the forum code is now http://www.theadamsreunion.com/forums?action=tarforum and the same with the url for my home button.

Thanks again,
Ravyn
Ravyn
-SMF Newbie in Training

Advertisement: