Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: MechSpecs - syyskuu 07, 2013, 07:43:51 IP

Otsikko: Can't get linktree to work for a newly added option.... ideas?
Kirjoitti: MechSpecs - syyskuu 07, 2013, 07:43:51 IP
Hey all,

Trying to add an option to my TOPNAV bar and I have that much working but the breadcrumbs don't work for it...

In the subs.php file I edit the HELP button (so that the help button isn't there) and changed that to....


),
'join' => array(
'title' => $txt['join'],
'href' => $scripturl . '?page=page1',
'show' => true,
'sub_buttons' => array(
),

),


The button works but it when I click on it the HOME button is still highlighted and indicated as being the "page that you are on" kinda thing.

What am I missing here?
Otsikko: Re: Can't get breadcrumbs to work for a newly added option.... ideas?
Kirjoitti: Arantor - syyskuu 07, 2013, 07:47:00 IP
The fact that the menu code is so naive that it doesn't know how to deal with that. It only knows how to cope with action=something. If the URL were action=join, it would highlight that correctly.

The only way around it is to modify the code a bit further down where it looks for $current_action and override it after it's set to 'home' with:

if (isset($_GET['page']) && $_GET['page'] == 'page1')
  $current_action = 'join';


(Please note, this is nothing to do with the breadcrumbs, also known as the linktree. If you would like some help with that please confirm)
Otsikko: Re: Can't get linktree to work for a newly added option.... ideas?
Kirjoitti: Arantor - syyskuu 07, 2013, 08:29:34 IP
Well, that's the main menu.

The breadcrumbs is the Simple Machines Community Forum » Customizing SMF » SMF Coding Discussion » Topic:  Can't get linktree to work for a newly added option.... ideas? bit under the menu.
Otsikko: Re: Can't get linktree to work for a newly added option.... ideas?
Kirjoitti: MechSpecs - syyskuu 07, 2013, 08:31:31 IP
Lainaus käyttäjältä: Arantor - syyskuu 07, 2013, 07:47:00 IP
The fact that the menu code is so naive that it doesn't know how to deal with that. It only knows how to cope with action=something. If the URL were action=join, it would highlight that correctly.

The only way around it is to modify the code a bit further down where it looks for $current_action and override it after it's set to 'home' with:

if (isset($_GET['page']) && $_GET['page'] == 'page1')
  $current_action = 'join';


(Please note, this is nothing to do with the breadcrumbs, also known as the linktree. If you would like some help with that please confirm)

Thank you I will look for what you are talking about. I thought it was breadcrumbs but hey we learn something new every day LOL

You talking about one of these options?


$current_action = $modSettings['sp_portal_mode'] == 3 && empty($context['standalone']) && empty($context['disable_sp']) ? 'forum' : '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';
elseif(empty($context['disable_sp']) && ((isset($_GET['board']) || isset($_GET['topic']) || in_array($context['current_action'], array('unread', 'unreadreplies', 'recent', 'stats', 'who'))) && in_array($modSettings['sp_portal_mode'], array(1, 3))))
$current_action = 'forum';
elseif ($context['current_action'] == 'register2')
$current_action = 'register';
elseif ($context['current_action'] == 'login2' || ($user_info['is_guest'] && $context['current_action'] == 'reminder'))
$current_action = 'login';
elseif ($context['current_action'] == 'groups' && $context['allow_moderation_center'])
$current_action = 'moderate';
Otsikko: Re: Can't get linktree to work for a newly added option.... ideas?
Kirjoitti: Arantor - syyskuu 07, 2013, 08:36:34 IP
No, you misunderstood me again... The bit you're talking about is the MENU. The linktree is the bit UNDER the menu and is unrelated to anything you've mentioned.

Yes, that's the code I referred to. Just above that code will do the job.
Otsikko: Re: Can't get linktree to work for a newly added option.... ideas?
Kirjoitti: MechSpecs - syyskuu 07, 2013, 08:38:28 IP
I managed to plug it in and got it working correctly! Thank you for the clarifications.

This actually will help me on two of my SMF sites LOL cheerrs!