CodeIgniter - Turn off controller function call?

1.3k Views Asked by At

I simply want to load the controller and not call a function based on the URI, so that I can then generate the page based on the following segments. How do I change the default behaviour to do this? eg.

example.com/class/function/ID >>> example.com/class/ID/ID

I thought all I needed to do was in config.php add:

$route['find/(:any)/(:any)'] = "find/$1/$2";

but this gives me a 404.


example.com/find/item/location

class Find extends CI_Controller {

private $s1;
private $s2;

function __construct()
{
    parent::__construct();
}

function index()
{
    $this->s1 = $this->uri->segment(2);
    $this->s2 = $this->uri->segment(3);
    $this->makePage();
}

function makePage()
{
    echo 'Page about ' . $this->s1 . 'in ' . $this->s2;
    //Get Data ($s1 & $s2)
    //Load View 
}
}
1

There are 1 best solutions below

0
On BEST ANSWER

figured it out, needed to add another function to call (findit);

$route['find/(:any)/(:any)'] = "find/findit/$1/$2";

function findit()
{
    $this->makePage();
}

this post I found was very helpful: CodeIgniter: Directing to functions with a URL segment