How to make a Custom Action as Active button in the Navigation Menu

Started by la muerte, July 06, 2015, 08:10:53 AM

Previous topic - Next topic

la muerte

Hello,

I know you can add custom forum tabs by adding following code to Subs.php
'latest' => array(
'title' => 'Latest',
'href' => $scripturl . '?action=recent',
'show' => $context['allow_search'],
),


And
elseif ($context['current_action'] == 'recent')
$current_action = 'recent';


The problem I have with this is that when you are on the recent page, the "Home" tab is the one set as the active tab which in reality is misguiding and incorrect.

After a lot of searching on the forums on how to resolve this, I found people suggesting to put following code in the recent.php:
global $context;
$_GET['action'] = "recent";
$context['current_action'] = "recent";


Further more, I have ensured that following code is in the Index.php:
'recent' => array('Recent.php', 'RecentPosts'),

Should this be modified to: 'recent' => array('Recent.php', 'Recent'),? When doing so I get the error: Could not load main template, although this is easily resolved by changing function RecentPosts to function Recent in the Recent.php file (but it doesn't seem to fix the issue either).

After all this, the recent tab still does not display as active when visiting the recent page.
I know there is a custom actions mod, but if you think about the issue in detail you will understand that this mod does not help in this particular scenario.

It would be lovely if after all those years and numerous related support topics someone could finally shed light on how to make this happen. I would really appreciate it if someone could elaborate on how to resolve this issue.

You can the issue live here: http://aquarity.eu/ (when opening the "Latest" tab, you will notice it is not set as the Active tab).

Thank you in advance!


la muerte

Quote from: la muerte on July 06, 2015, 08:10:53 AM
I know there is a custom actions mod, but if you think about the issue in detail you will understand that this mod does not help in this particular scenario.

The Custom Actions mod only allows you to make custom pages, I want to make this functionality work on existing pages and therefore I can not depend on it.

Steve

Quote from: la muerte on July 06, 2015, 08:10:53 AMYou can the issue live here: http://aquarity.eu/ (when opening the "Latest" tab, you will notice it is not set as the Active tab).

Does one have to register to see this?
DO NOT pm me for support!

la muerte

Hello Steve,

Not at all, you can simply press on the Articles tab in the navigation menu to see that once the page opens the tab is not highlighted as it is intended to be.
You can click any of the other tabs to compare the result.

I have noticed quite a lot of support topics over the years describing this exact same issue and from what I've seen none of those were resolved, which is why I did my best to provide all information needed to crack this case.

Steve

DO NOT pm me for support!

la muerte

Oh snap, I do apologize I am still developing this website and the image used currently says "Articles" which shows the Recent posts. I will edit the image shortly so that it says "Recent" instead. Sorry for the confusion.

The issue however remains the same.

Gluz

For:
'latest' => array(
'title' => 'Latest',
'href' => $scripturl . '?action=recent',
'show' => $context['allow_search'],
),


the code for the active tab should be:
elseif ($context['current_action'] == 'recent')
$current_action = 'latest';


As that is what the Menu is looking for.

la muerte

Hey Gluz,

Nice catch and thank you very much! That completely solved my issue.

Thanks again

Advertisement: