Defining current actions for custom SimplePortal page buttons

Started by cralor, September 04, 2010, 01:58:03 PM

Previous topic - Next topic

cralor

Hello. I recently knew how to do this, but lost the Subs.php where I had used it, so I need to figure it out again ;)

I have created a page (using Simple Portal, specifically - I did the same with TinyPortal previously) "?page=PAGE" and want to code (in Subs.php) that it is the current_action.

In layman's terms: I have just created a custom button. If you are visiting that page, I want the button to be highlighted to represent that is the page you are on.

What was the code to do this?? (the if statement)

Thank you!!

ɔɔɔɔɔɔuɥoɾ

You need to add an elseif statement in that array


SMF 2.0 RC5

   
Webhost to New Webhost file transfer service, PM me - Fast transfers

cralor

Sorry for being blunt, but can't you tell I already knew that? I referred to the if statement, but it's fine if you didn't catch that.

I already know this (I'm not a PHP noob here, else I would have much more significant issues with tweaking SMF).

I need to know the ENTIRE elseif statement. Thank you for your post!

ɔɔɔɔɔɔuɥoɾ

#3
Hmmm, coming to think of it, it probably will not work anyway.

Since its not an action, its a page, index.php?page=blahblah

but if it did work using the action array you would do it like this.
Assuming your custom button is as follows;

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



	
// 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';
//adding your actions start.
	
elseif (
$context['current_action'] == 'page1')
	
	
$current_action 'custom1';
//adding your actions end
	
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';


I'm not sure if that will even work, but if you have had it work before, it would have likely been something like that


SMF 2.0 RC5

   
Webhost to New Webhost file transfer service, PM me - Fast transfers

cralor

Alright, well I think it might have been the fact that TinyPortal continued to use actions for it's pages. Instead, I have used a PHP URL grab to try and match it.

Here is the code for those who would like it:

$curPageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$curPageURL .= "s";}
$curPageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$curPageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$curPageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}


Then, for your if statement, do this:
elseif ($curPageURL == $scripturl . '?page=PAGENAMHERE')

(And just make $current_action the name of your button you made.)

Thanks for the help anyways!


ɔɔɔɔɔɔuɥoɾ



SMF 2.0 RC5

   
Webhost to New Webhost file transfer service, PM me - Fast transfers

Advertisement: