Customizing SMF > SMF Coding Discussion

Highlighting Different Active Tab

(1/2) > >>

Egoista:
Hello everyone, how are you?

I'm having a bit of trouble trying to make a particular tab active.

I thought it was in the Subs.php but then I saw the index.template.php:



--- Code: ---echo '
<li id="button_', $act, '">
<a class="', $button['active_button'] ? 'active ' : '', 'firstlevel" href="', $button['href'], '"', isset($button['target']) ? ' target="' . $button['target'] . '"' : '', '>
<span class="', isset($button['is_last']) ? 'last ' : '', 'firstlevel">', $button['title'], '</span>
</a>';
--- End code ---

I changed the original coding of buttons in Subs.php to all buttons except "Home" into sub-buttons under one button called "Forum."

As of right now, "Home" is highlighted. I want "Forum" to be highlighted.

Thank you all in advance for any help and advice

Labradoodle-360:
Hey there, and welcome to the SMF Community!

I went ahead and moved this topic to SMF Coding Discussion because it fits in better here/there.

As for your question, you'll need to modify Subs.php to alter that, it'd be fairly easy, but you'll need to edit a block below the $buttons array.

Egoista:
Thank you for the response and I apologize for posting in the wrong board.

What exactly in the buttons array do I change?

I don't see anything that involves and active tab.

Kays:
Hi, I think you missed the "bit further on down" in Lab's post.  :)

What your looking for is the following:


--- 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';
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';


--- End code ---

I think that following should do what you're looking for (not tested)


--- 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 (!empty($context['current_action']))
$current_action = 'forum';

--- End code ---

Also since you've moved the buttons I suspect that you're getting a lot of undefined index errors.

The next bit of code there


--- Code: (find) --- $context['menu_buttons'][$current_action]['active_button'] = true;

--- End code ---

Change that to:


--- Code: --- if (isset($context['menu_buttons'][$current_action]))
$context['menu_buttons'][$current_action]['active_button'] = true;

--- End code ---

Egoista:
Thank you SO much. I did what you told me for 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 (!empty($context['current_action']))
$current_action = 'forum';
--- End code ---

But I also had to change



--- Code: --- $current_action = 'home';
--- End code ---

to



--- Code: --- $current_action = 'forum';
--- End code ---

Thank you. Both of you.

I have one last question and I didn't want to bother by adding another thread.

I want to make regular pages out of the theme I'm using.

As in, I don't want just the forum but an entire website, but I want to keep the same theme.

How would I go about doing that? Is there a header.php and footer.php that I can just include in a PHP file?

Navigation

[0] Message Index

[#] Next page

Go to full version