Welcome Guest, Not a member yet? Register   Sign In
Is it possible to change the name of a controller based on a configuration value?
#1

[eluser]Th3FalleN[/eluser]
What i am attempting to do is write an admin control panel for a script, and would like to give the end user the ability to change its url from its default ie: admin to a directory of their liking. Is this possible and if so how would i go about doing it?
#2

[eluser]toopay[/eluser]
Please, put your thread elsewhere. You will not get any apropriate help, since this is a section that intend to use to submit bug.
#3

[eluser]davidbehler[/eluser]
What you could do is this:
Define routes for all controllers you have in /config/routes.php, e.g. like this:
Code:
$route['controller_name'] = 'controller_name';
$route['controller_name/(:any)'] = 'controller_name/$1';
$route['controller_name2'] = 'controller_name2';
$route['controller_name2/(:any)'] = 'controller_name2/$1';
Now after you've done this for all your controllers you've made sure that all calls to them actually reach them. Then you add a final route that catches all controllers/url that are not listed above and sends it to a special controller that decides what to do depending on the given url, e.g. checks if the given url is the admin url the user has chosen:
Code:
$route['(:any)'] = 'my_routing_controller/check/$1';

Now in that controller you check the parameter and redirect or what ever depending on the result:
Code:
class My_routing_controller extends CI_Controller {
  function __construct()
  {
    parent::_construct();
  }

  function check($uri)
  {
    $this->load->model('Check_model');
    $real_controller = $this->Check_model->get_real_controller($uri);
    redirect($real_controller);
  }
}

This is totally untested, but that's pretty much what I do for projects where users can choose their own url_title for their profile or something.
#4

[eluser]toopay[/eluser]
NOTE (from the description of this forum section): If you are not sure whether your unexpected behavior issue is a bug, post here for help before reporting in the bug tracker. Note: Please search the forums first before submitting a bug report.
#5

[eluser]osci[/eluser]
+1
[quote author="toopay" date="1305397939"]NOTE (from the description of this forum section): If you are not sure whether your unexpected behavior issue is a bug, post here for help before reporting in the bug tracker. Note: Please search the forums first before submitting a bug report.[/quote]

I'm also tired of viewing anything anywhere. The only thing i haven't discovered yet is posting codeigniter reactor questions to core :/
#6

[eluser]Th3FalleN[/eluser]
I apologize i did not realize this was the wrong section.
#7

[eluser]fivefinger-bd[/eluser]
He didn't understand that this is not the right place. New users can face this problem. We should make them understand politely. Then he'll never do this again.




Theme © iAndrew 2016 - Forum software by © MyBB