Welcome Guest, Not a member yet? Register   Sign In
URI like controller/var/controller/var ?
#2

[eluser]CroNiX[/eluser]
I think even more intuitive would be /cars/honda/civic
You could even do /cars/honda/civic/2012 to include the model year

If you only want one controller, instead of having to have a "cars" controller, you'd just

Code:
$route['cars/(:any)/(:any)'] = 'brand/view/$1/$2';
$route['cars/(:any)'] = 'brand/view/$1/';
$route['cars'] = 'brand/view';

And the brand controller would look something like
Code:
class Brand extends CI_Controller {

  public function view($make = '', $model = '')
  {
    if ( ! empty($make))
    {
       //They entered a car Make
    }
    if ( ! empty($model))
    {
       //They entered a car Model
    }
  }
}

This would allow for urls like:
/cars (list all car makes)
/cars/honda (list all hondas)
/cars/honda/civic (list all honda civics)

There are many ways to do this, but hopefully this gives you an idea.


Messages In This Thread
URI like controller/var/controller/var ? - by El Forum - 08-06-2014, 05:20 PM
URI like controller/var/controller/var ? - by El Forum - 08-06-2014, 06:14 PM
URI like controller/var/controller/var ? - by El Forum - 08-07-2014, 12:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB