Welcome Guest, Not a member yet? Register   Sign In
remove index from url not index.php
#1

[eluser]Jagar[/eluser]
Finally, somebody had posted some code that would allow one to use unlimited folders in the controllers folder, and since I have that I have removed many routings.

Everything is excellent except when Ihave to pass a paramter to a function in the controller I need to include index such as:
Code:
http://localhost/admin/change_password/index/admin_1

Is there an easy way to remove that either through routing or any tricks that may do it.

Thanks in advance.
#2

[eluser]Dam1an[/eluser]
Yeah you can do it using routes, such as
Code:
$route['admin/change_password/admin_1 '] = "admin/change_password/index/admin_1";
#3

[eluser]Jagar[/eluser]
But there are many urls, that's the problem, I did that first and I was about to do it for all of them, but thought maybe there's a better way to do it, for all of them

THanks
#4

[eluser]Jagar[/eluser]
I"m going to use routing, It doesn't seem so bad.

Thanks for your reply by the way!
#5

[eluser]Evil Wizard[/eluser]
you could use _remap to force all requests for the controller to go through a specific method, removing the need to name the method in the URL and using something like...

Code:
public function _remap($strMethod='index')
{
    call_user_func_array(array(&$this, 'index'), array_slice($this->uri->segment_array(), 2));
}
public function index($mxdAdminId)
{
    /*
    * access the passed parameter as usual :o)
    */
}

So only the name of the controller is required in the URL.
#6

[eluser]Jagar[/eluser]
I think I will go with routing. This is how I'm doing it now:
Code:
$route['admin/manage/(change_password|delete|change_status)/(.*)'] = "admin/manage/change_password/index/$1";

It seem to be working great.

Thanks for your solution though




Theme © iAndrew 2016 - Forum software by © MyBB