php - CodeIgniter route overridden by controller/method -


i have in routes.php:

$route['ctrller1/method1/video/(:num)'] = 'ctrller2/method2/$1'; 

i have controller named ctrller1 has method:

function method1 ($str = null) {     // } 

the problem have use controller2 coz can't or shouldn't edit controller1. want seemingly simple but, apparently, ci doesn't want work me.

when url:
domain.com/ctrller1/method1/edit
invoked, want method inside ctrller1 called, if domain.com/ctrller1/method1/videos/1
invoked want method in ctrller2 called.

it seems correct me won't work. so, must missing something. i've tried adding routing:

$route['ctrller1/method1/(edit)'] = 'ctrller1/method1/($1)'; 

but it's no go. see wrong here?

at time when work routes, permissions (firewall, etc;) order important. typically want organize routes in order:

  1. most defined
  2. less defined
  3. general / fallback

to clarify, means order routes should this:

$route['ctrller1/method1/videos/view/(:num)'] = 'ctrller2/method3/$1'; $route['ctrller1/method1/videos/(:num)'] = 'ctrller2/method2/$1'; $route['ctrller1/(:num)'] = 'ctrller2/method1/$1'; 

when url called, route table goes through , finds first closest match, else traverses next route.

in case want this:

domain.com/ctrller1/method1/videos/1
domain.com/ctrller1/method1/edit

reasoning is, video's route more specific, , special case, route controller behind scenes.

here routes should (not tested, should it):

$route['ctrller1/method1/videos/(:num)'] = 'ctrller2/method2/$1'; $route['ctrller1/method1/edit'] = 'ctrller1/method1'; 

as side, note, curious why format ctrller1/method1/videos/ , not ctrller1/videos/view/12355 or ctrller1/videos/edit/12355, method1 seems confusing. again don't have details here.

hope works you, if not comment, , revisit question if clarify little more.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -