Uutiset:

Wondering if this will always be free?  See why free is better.

Main Menu
Advertisement:

Question regarding "active" tabs in Nav

Aloittaja azasmith, marraskuu 13, 2013, 12:56:59 IP

« edellinen - seuraava »

azasmith

Hi guys, I've done a fair bit of searching, but nothing really matches what I'm looking for.

I've created two new tabs in my navigation, however when those pages are active, the active tab is still "Home".

I looked in subs.php for the part that dictates the "active" tabs, but what I've linked to isn't an action.

My links are to two boards. So the URLs I've linked are index.php?board=2.0 and index.php?board=3.0

Any ideas?

Arantor

Yeah, there's no really good way to make them active without modifying the menu code, because it's not really designed for that.

The active tab is designated by an action, i.e. action=profile or action=admin, except boards aren't actions and thus cannot be normally highlighted.

What code, exactly, did you add? We'll see if we can't make the right changes for you.
Holder of controversial views, all of which my own.


azasmith

In subs.php in between Home & Help

'Board' => array(
                'title' => 'The Board',
                'href' => '/forum/index.php?board=2.0',
                'show' => true,
                'sub_buttons' => array(
                ),
            ),
            'Grid' => array(
                'title' => 'The Grid',
                'href' => '/forum/index.php?board=3.0',
                'show' => true,
                'sub_buttons' => array(
                    'Mixes' => array(
                        'title' => 'Mixes',
                        'href' => '/forum/index.php?board=4.0',
                        'show' => true,
                    ),
                    'Releases' => array(
                        'title' => 'Releases/Tracks',
                        'href' => '/forum/index.php?board=5.0',
                        'show' => true,
                    ),
                ),
            ),


Removed the URLs, but you get the idea. I have noticed that when I got to Quote an existing thread, the action becomes post, which does set Board to active. But it also does this when I'm in Grid as well. So that's not right.

Thanks.

Arantor

There is absolutely no reason for either of those to become active under any circumstances unless for some strange reason you declared index.php?action=Board or index.php?action=Grid, not even if you removed the Home button...

Makes me wonder if you changed anything else as well...
Holder of controversial views, all of which my own.


azasmith

Lainaus käyttäjältä: Arantor - marraskuu 13, 2013, 01:13:09 IP
There is absolutely no reason for either of those to become active under any circumstances unless for some strange reason you declared index.php?action=Board or index.php?action=Grid, not even if you removed the Home button...

Makes me wonder if you changed anything else as well...

Are you always this patronising? I followed a thread on here to make these changes and afterwards found out that only "actions" get set as active. I'm very sorry that my php skills don't match yours, but I was asking a question, this is what the forums are for.

http://www.simplemachines.org/community/index.php?topic=261880.0  -  If you disagree with this advice, why is it on the forum. And easily found using Google.

All Colours Sam

@azasmith From what I understand you want to add a button (or buttons) that will link to a specific board, am I correct?

If that is what you want then the active tab would be the "home" one or "forum" if you use a portal. You can see the same behavior here on this site, go to any board or any topic, the active button will always be the "home" one.  Thats why I suggest you to leave the button as it is and left the home button to be the active one.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

azasmith

Lainaus käyttäjältä: Suki - marraskuu 13, 2013, 02:07:07 IP
@azasmith From what I understand you want to add a button (or buttons) that will link to a specific board, am I correct?

If that is what you want then the active tab would be the "home" one or "forum" if you use a portal. You can see the same behavior here on this site, go to any board or any topic, the active button will always be the "home" one.  Thats why I suggest you to leave the button as it is and left the home button to be the active one.

Hi Suki,

Yeah that's correct, basically I only have two boards, but numerous child boards, so my thinking was to have "quick links" in the navigation to each place.

Thought from reading the thread that I posted above that it would also be possible to amend the active links, not to worry.
Thanks.


emanuele

Since you are already editing the code, azasmith, you can just add:

elseif (!empty($board) && $board == 2)
$current_action = 'Board';
elseif (!empty($board) && in_array($board, array(3, 4, 5)))
$current_action = 'Grid';

after:
$current_action = 'moderate';
and of course:
global $board;
somewhere at the beginning of the function.

I'd suggest you to also change all the:
'href' => '/forum/index.php?board=4.0',
to something like:
'href' => $scripturl . '?board=4.0',


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

azasmith

Lainaus käyttäjältä: emanuele - marraskuu 13, 2013, 02:40:36 IP
Since you are already editing the code, azasmith, you can just add:

elseif (!empty($board) && $board == 2)
$current_action = 'Board';
elseif (!empty($board) && in_array($board, array(3, 4, 5)))
$current_action = 'Grid';

after:
$current_action = 'moderate';
and of course:
global $board;
somewhere at the beginning of the function.

I'd suggest you to also change all the:
'href' => '/forum/index.php?board=4.0',
to something like:
'href' => $scripturl . '?board=4.0',

A million internets to you. Thanks Emanuele, works brilliantly.

Advertisement: