We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Custom module: redirect() to page in CP

Development and Programming

Nico Meijer's avatar
Nico Meijer
41 posts
15 years ago
Nico Meijer's avatar Nico Meijer

Hey everyone!

Building a small module with a backend control panel using ExpressionEngine v2.1.0 Build 20100810.

I’m having issues redirecting users to the module’s index page in CP.

Here is a snippet I’ve been trying:

$uri = BASE.AMP.'C=addons_modules'.AMP.'M=show_module_cp'.AMP.'module=rollen';
$uri = html_entity_decode($uri);
redirect($uri);

redirect() seems to always redirect to /index.php, so whatever I make out $uri to be, I get redirected to somewhere outside of CP.

An example would be:

http://hostname.example.com/index.php/index.php?S=22e3308a58a571e3386aa2aac43a227a11b54321&D=cp&C=addons_modules&M=show_module_cp&module=rollen

That URI needs to be:

http://hostname.example.com/cms/index.php?S=22e3308a58a571e3386aa2aac43a227a11b54321&D=cp&C=addons_modules&M=show_module_cp&module=rollen

I can use this for redirect and still end up outside of CP:

redirect('/cms/'.$uri);

is redirected to

http://hostname.example.com/index.php/cms/index.php?S=22e3308a58a571e3386aa2aac43a227a11b54321&D=cp&C=addons_modules&M=show_module_cp&module=rollen

Again: http://hostname.example.com/index.php added to the URL I need.

Can anybody shed some light on this issue? Did I miss something in the User Guide?

Thanks!… Nico

       
Aenarion's avatar
Aenarion
51 posts
15 years ago
Aenarion's avatar Aenarion

You need to add some code to hooks.php

Check a plug-in called quick save it will help you.

       
Greg Aker's avatar
Greg Aker
6,022 posts
15 years ago
Greg Aker's avatar Greg Aker

use $this->EE->functions->redirect(); Do a project ‘find’ for ‘functions->redirect(’ and you’ll see how it is used.

-greg

       
Nico Meijer's avatar
Nico Meijer
41 posts
15 years ago
Nico Meijer's avatar Nico Meijer

@Aenarion Thanks for your suggestion. I’ll check it out!

@Greg Thanks to you aswell. It’s working perfectly. 😊

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.