Custom menu not being detected as current action

Started by xiuide, April 23, 2008, 09:32:22 PM

Previous topic - Next topic

xiuide

Im not sure if this is a bug, or my stupidity, so, im posting here first.

I am working on an intergrated website solution using SMF using SSI.php and the related php calls (including template functions from the theme(s)) I edited the menu items a bit, chaing home to forums (as well as adding a new constant for it), and adding a new "home" menu item as shown below:

$buttons = array(
'home' => array(
'title' => $txt['home'],
'href' => 'http://www.mysite.us',
'show' => true,
'sub_buttons' => array(
),
),
'forum' => array(
'title' => $txt['forum'],
'href' => $scripturl,
'show' => true,
'sub_buttons' => array(
),
),


I then changed $current_action = 'home'; to $current_action = 'forum';

the menu works exactly as you would expect, except that it seems that the software is not detecting that "home" is the active page the user is visiting, as in, when you hover over the home link, you will get the hover color, but, once you click on it, it shows the "forum" tab as the active page. i have tested this on several 2.0b3 compatable themes (overview, blackrain... ect.)

you can see what im talking about at hxxp:www.thegodsofwar.us [nonactive]

if anyone could shed some insight that would be great, and also, if this has been posted before, im sorry. i searched, but didnt find anything to this problem.

rsw686

I called the menu item 'front' and added this at the button of that function in Subs.php


// Check if on the front page
if ($_SERVER['SCRIPT_NAME'] == '/index.php')
$current_action = 'front';
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

xiuide

#2
that would work if I was making a call to a page in my forum directory, but, im not :-/ I spose I should have specified that, sorry, my server setup is like this

mysite.com/index.php
forums.mysite.com/index.php (mysite.com/forums  ...they are both the same thing)

so what happens is that the script detects index.php from hxxp:forums.mysite.com [nonactive] and instead of the forum tab showing active, it shows the home tab active (when im on the fourm), complete reversal of what origionally happens, but, like I said, this tip will come in handy for when/if I add pages directly into the forum directory

rsw686

Have a look at the site in my sig. Mine is setup

thereptilefile.com/index.php as the front page
thereptilefile.com/forum/index.php as the forum

That code works for my menu. The SCRIPT_NAME is the part after the domain name. So when on the SSI page it sees /index.php and on the forum page it sees /forum/index.php
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

xiuide

hmm ok, maybe i missunderstood where to put that bit of code from you... i have it placed right before $current_action='forum' so...


if ($_SERVER['SCRIPT_NAME'] == '/index.php')
$current_action = 'front';
else{
$current_action = 'forum';
};


if im wrong, then girr to me for not totally understanding what you said in the first post >.<

rsw686

It needs to go in the button of the Subs.php file where you added in the menu item. Here's a section of the code


// 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']]))
$current_action = $context['current_action'];
elseif ($context['current_action'] == 'search2')
$current_action = 'search';
elseif ($context['current_action'] == 'theme')
$current_action = isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'pick' ? 'profile' : 'admin';

// Check if on the front page
if ($_SERVER['SCRIPT_NAME'] == '/index.php')
$current_action = 'front';
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

SleePy

if ($_SERVER['SCRIPT_NAME'] == '/index.php')

That may not work because he uses a sub domain.

Doing something like
if (SMF == 'SSI')
would be better as it would only run if you where using SMF through SSI.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

rsw686

True I just wasn't sure if he wanted all his SSI pages to register as home. You could do a combination of the two if you only want the home SSI page to register and not other SSI pages.


if (SMF == 'SSI' && $_SERVER['SCRIPT_NAME'] == '/index.php')
The Reptile File
Everything reptile for anyone reptile friendly

Aquaria Talk
Community for freshwater and saltwater aquariums enthusiasts

xiuide

if(SMF == 'SSI) seemed to work out great, so thanks for that, however, for some odd reason, when i tried to use if ($_SERVER['SCRIPT_NAME'] == '/index.php') where you had put it, rsw686 it still was not working, but, the imidate fix is done, and its what i needed (for now at least) and I can tinker with the other code and see if i can get it working at another date, thanks both of you for your help

Sarge

Hello xiuide, have you made any further progress, or is the case solved? I just want to make sure. :)

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Quote
<H> I had zero posts when I started posting

Advertisement: