1

My controllers and methods map to sections and pages so I use that to highlight current navigation items and show page templates (via $this->router->class..). But I've struck a bit of a problem, I have the following structure for doctor test results:

website.com/doctor/results/

So a 'doctor' controller has a method 'results' that loads a page listing of results. All good.

But there is a link next to each result listed, i.e. 'view details' to show details of that test. Functionally, clicking this link takes you to a 'test' controller with it's own method 'view' to show a page of details for that particular test. But visibly you should still be in the 'doctor' section, 'results' subsection.

I'm not sure how to achieve that? without rethinking the navigation as whole (which up until now seemed pretty good).

tereško
  • 58,060
  • 25
  • 98
  • 150
gio
  • 991
  • 3
  • 12
  • 24

2 Answers2

0

You could create a subdirectory in your controllers directory thats called "doctor" and then use "result" as your controller name.

To display all your results you would then use the main "index()" method. You could then have a another method call "test()" to display your tests.

Example:

Directory structure:

application/controllers/doctor/results.php

Your results.php file would then be like so:

function index()
{
// all results here
}

function test()
{
// test result display here
}
0

The common way to do this is to use a route:

In the file /application/config/routes.php, add this route:

$route['doctor/test-results/(:any)'] = 'test/view/$1';

Where test-results is whatever you want the url segment to be (the page you'll link to).

This basically says:

Any url that is doctor/test-results/something should really load test/view/something

You can do quite a bit with routes. Read more on routing in the User Guide

If you find $this->router->class/method is not working out, try experimenting with some functions from the URI Class

Wesley Murch
  • 101,186
  • 37
  • 194
  • 228
  • Thanks. Hmmm, perhaps I should be using the URI class instead (segments) to determine the template and current nav instead. I tried your example above for the route solution but `$this->router->class;` was still returning 'test' ? instead of doctor. I may have missed something though! – gio May 06 '11 at 23:06