News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

problemes modifying smf menu

Started by glennmckenna, November 29, 2015, 07:38:37 AM

Previous topic - Next topic

glennmckenna

hi all,

I'm busy modifying the smf menu in subs.php
I've verified the modification that i made with the parse of this mod:
http://custom.simplemachines.org/mods/index.php?mod=2870

but my problem is that it's highlighting the wrong tab in the menu
for example:
when I'm on my home page the home button is highlighted
but when I'm the forums index the button for my home page is still highlighted and not the forum button

I've attached all the files that i think that you'll need including images to show what the problem is

Gluz

You need to change the $current_action to go default to the forum tab and not to home.

Also, you need an extra elseif to check the url and if it's your home url without the forum part then set $current_action to home.

glennmckenna

Quote from: Gluz on November 29, 2015, 08:50:50 AM
You need to change the $current_action to go default to the forum tab and not to home.

Also, you need an extra elseif to check the url and if it's your home url without the forum part then set $current_action to home.
igave this ago but it didn't work

if ( $_SERVER['REQUEST_URI'] == "http://localhost/mdl/")
{$current_action = 'home';}
else
{$current_action = 'forum';}


or could it be that i need to do somzthing like this :

if ( $_SERVER['REQUEST_URI'] == "http://localhost/mdl/")
{$current_action = 'home';}
elseif
{$current_action = 'forum';}


or have i got it totally wrong?

Gluz

Below the menu button array is the if-elseif-else check to determine the current_action, did you put that in there? Because it's important where you put that.

Gluz

I can't edit my last post, so, here is what you need to change to get it working, search in /Sources/Subs.php

The part where it says:
$current_action = 'home';

That is what you need to change to forum, and then in the if with a bunch of elseif, and after the last you can add yours like this:
elseif ($_SERVER["SCRIPT_URI"] == 'http://localhost/mdl/')
$current_action = 'home';


The $_SERVER["REQUEST_URI"] variable is only the /mdl/ in your case, and you can use that if you want.
This should show you the Forum tab highlighted when you are in the forum and the Home button only where you are in your home page.

glennmckenna

Quote from: Gluz on December 06, 2015, 08:57:57 PM
I can't edit my last post, so, here is what you need to change to get it working, search in /Sources/Subs.php

The part where it says:
$current_action = 'home';

That is what you need to change to forum, and then in the if with a bunch of elseif, and after the last you can add yours like this:
elseif ($_SERVER["SCRIPT_URI"] == 'http://localhost/mdl/')
$current_action = 'home';


The $_SERVER["REQUEST_URI"] variable is only the /mdl/ in your case, and you can use that if you want.
This should show you the Forum tab highlighted when you are in the forum and the Home button only where you are in your home page.
thnks for the help but i got no luck
i get this error on the home page

Notice: Undefined index: SCRIPT_URI in C:\xampp\htdocs\mdl\forum\Sources\Subs.php on line 4177

i've ttatched a cop of the subs file

may i add that these are they link to the page
localhost/mdl/                     ->for the home page
localhost/mdl/forum/          ->for the forum home page

Gluz

Oh, well, then try with:
if ( $_SERVER['REQUEST_URI'] == "/mdl/")

That should work, I don't know why SCRIPT_URI is not defined in your case.

glennmckenna

Quote from: Gluz on December 07, 2015, 09:11:15 AM
Oh, well, then try with:
if ( $_SERVER['REQUEST_URI'] == "/mdl/")

That should work, I don't know why SCRIPT_URI is not defined in your case.
euh still no luck could it be due to the fact that i'm useing SSI.php ?

Gluz

No, the SSI just load all the things when you use the header and footer, so, something different is happen.

I tested in local, this works just right. If don't work in you install, then you have something misconfigured in your local server, because that is how I assign the current tab for other softwares integrated with SSI to match my forum theme and feel.

glennmckenna

thanks again for your help
but....
I've still got the problem even on the server at OVH
here a link to the site on OVH
mdl-palissy.fr

any help would be great

Gluz

That is because the url in the first button is not ok, that is ok for a local installation but not for a hosted server.

Also in that local you have the forum in a subdirectory, and the home page also is in a subdirectory, in the hosted server it's directly in the site root, so you need to adjust that.

Later I will attach you what it works on the hosted server, when I get back to home.

glennmckenna

Quote from: Gluz on December 09, 2015, 08:06:41 PM
That is because the url in the first button is not ok, that is ok for a local installation but not for a hosted server.

Also in that local you have the forum in a subdirectory, and the home page also is in a subdirectory, in the hosted server it's directly in the site root, so you need to adjust that.

Later I will attach you what it works on the hosted server, when I get back to home.
ah yes indeedi shal give those modification a go and let you know how i got on

Gluz

Compare your file (I see that you fixed something, only left the active tab) with this, and try it, I'm pretty sure this will be what you want.

glennmckenna

Quote from: Gluz on December 10, 2015, 02:43:03 PM
Compare your file (I see that you fixed something, only left the active tab) with this, and try it, I'm pretty sure this will be what you want.
great :D
it works
many thanks
may i ask what is the difference between the 2 commandes (the one i was using before and the one you just gave me) in the elseif ?

Gluz

REQUEST_URI is the relative path to the actual directory from your root directory, it means that it doesn't contain the server name (http://blabla.bla) only the path after that, and you have it in the elseif with the server name (http://localhost/ or in case of the hosted server your URL).

SCRIPT_URI is not always populated, but it have the same meaning.

glennmckenna

Quote from: Gluz on December 10, 2015, 03:53:19 PM
REQUEST_URI is the relative path to the actual directory from your root directory, it means that it doesn't contain the server name (http://blabla.bla) only the path after that, and you have it in the elseif with the server name (http://localhost/ or in case of the hosted server your URL).

SCRIPT_URI is not always populated, but it have the same meaning.
ok many thanks yet again

Advertisement: