2
$this->EE->functions->redirect(BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=module_name_here' . '#tabsettings');

EE v2.9.2

I want to redirect the user after the person submits the form, then it fires off the redirect function.

When I append #tabsettings, it redirects me to the Admin CP login form. Here is the URL it directs me to:

http://project.dev/admin.php?/cp/login&return=Qz1hZGRvbnNfbW9kdWxlcyZhbXA7TT1zaG93X21vZHVsZV9jcCZhbXA7bW9kdWxlPWVlX3ZiX2ludGVncmF0aW9u#tabsettings

If I remove the #tabsettings, it will keep me within the module control panel, but I want it to load the settings view, which needs the #tabsettings to know which part of the view to load.

$this->EE->functions->redirect(BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=module_name_here');
1
  • The hashtag is getting in the way of the S parameter EE adds at the end of the url, if possible try using a GET variable instead. $url .= "&hashtag=tabsettings" Commented Mar 18, 2015 at 17:48

1 Answer 1

1

Brandon is correct - EE does not like a hash in a redirect URL.

Instead, try using flash data for this.

$this->EE->session->set_flashdata('selected-tab', 'settings');
$this->EE->functions->redirect(BASE . AMP . 'C=addons_modules' . AMP . 'M=show_module_cp' . AMP . 'module=module_name_here');

Then, in your module code:

if($tab = ee()->session->flashdata('selected-tab') && $tab == 'settings')
{
    // Add something here to your markup so that your JS will select the tab you want
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.