Question

I'm having a problem with PyroCMS and CodeIgniter URI Routing.

I have a page (majors_list) has a child page (major) , which it has a child page too called (course).

$route['majors_list/major/(:any)'] = 'pages/view/majors_list/major';
$route['majors_list/major/(:any)/course/(:any)'] = 'pages/view/majors_list/major/course';

The first routing, is to view the major page which contains all the courses.

The second routing, conflicts with the first routing, and it is used to view the course information.

When I comment the first routing, the second routing works, but the first stops, and vice versa.

A real example:

majors_list/major/Dentistry/course/dental_material
Was it helpful?

Solution

You need to swap them around. To me it looks like any route that matches the second one will also match the first one, so it never reaches the second one, therefore swapping them will solve the issue.

Alternatively, you could use the regex syntax for routing and place a dollar sign at the end of the regex for the first route to exclude routes that continue after that point.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top