SMFHacks.com

SMF Classifieds => Support => Topic started by: exit on February 04, 2018, 12:34:04 pm

Title: custom menu detecting the current action
Post by: exit on February 04, 2018, 12:34:04 pm
So, I'm trying to build a menu, not using smf menus. Basically I'm trying to get the active action, but with no luck. What am I doing wrong?

Code: [Select]
<li>
<a class="' , $current_action == 'SPortal' ? 'active' : 'not-active' , '" href="' , $scripturl , '">Home</a>
</li>
<li>
<a class="' , $current_action == 'classifieds' ? 'active' : 'not-active' , '"href="' , $scripturl , '?action=classifieds">Marketplace</a>
</li>

In this example, I'm trying to get the current actions for simpleportal and for the classifieds mod.
Title: Re: custom menu detecting the current action
Post by: SMFHacks on February 04, 2018, 12:54:44 pm
Is  $current_action a global set in the same function you are in?
You can also do with $_REQUEST['action']  to check the action name.
Title: Re: custom menu detecting the current action
Post by: exit on February 04, 2018, 01:07:48 pm
Is  $current_action a global set in the same function you are in?
You can also do with $_REQUEST['action']  to check the action name.

I added $current_action to the global set, now it identifies the action :)

Code: [Select]
' , $current_action == 'classifieds' ? 'current' : 'not' , '
this is not retrieving 'current' though, anything wrong here?
Title: Re: custom menu detecting the current action
Post by: SMFHacks on February 04, 2018, 01:13:17 pm
I would echo the output of $current_action  to see what it is returning.
Title: Re: custom menu detecting the current action
Post by: exit on February 04, 2018, 01:14:34 pm
I would echo the output of $current_action  to see what it is returning.

How can I do that?
Title: Re: custom menu detecting the current action
Post by: SMFHacks on February 04, 2018, 01:31:32 pm
on it's own line
echo  $current_action;
Title: Re: custom menu detecting the current action
Post by: emilyturner on March 17, 2018, 04:25:33 am
Thanks a lot for this reply, it has helped me too