CodeIgniter Forums
Simple routing problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Simple routing problem (/showthread.php?tid=24505)



Simple routing problem - El Forum - 11-11-2009

[eluser]Aidy[/eluser]
I have followed the use guide examples and have set up a route

Code:
$route['Food-Safety/Level-2-Award-in-Food-Safety-in-Catering-CIEH'] = "courses/course/30/300";

The route seems to be loading loading the controller but without the last 2 segments eg courses/course.

The controller works fine for www.somedomain.com/courses/course/30/300 here is my controller code.

Code:
function course()
    {
        //category id
        $cat_id = (int) $this->uri->segment(3);
        
        //course id
        $co_id = (int) $this->uri->segment(4);
            
        $data['nav_list'] = $this->coursenav->course_list($cat_id, $co_id);
        
        $data['course'] = $this->model_courses->get_course_info($co_id);        
        $data['dates'] = $this->model_courses->get_course_dates($co_id);
        
        $this->load->view('course', $data);
    }

Any help appreciated?


Simple routing problem - El Forum - 11-11-2009

[eluser]BrianDHall[/eluser]
Try this:

Code:
function course($cat_id = null, $co_id = null )

Then get rid of accessing by segment.

Otherwise you need to check out rsegment() as you are using routing to change the uri segments:

http://ellislab.com/codeigniter/user-guide/libraries/uri.html


Simple routing problem - El Forum - 11-11-2009

[eluser]Aidy[/eluser]
Hey Brian

Thats Great, thanks alot.

I should have checked that section of the user guide.