$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');
  • 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" – BrandonOHara Mar 18 '15 at 17:48

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

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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