Reputation: 26501
I have a problem. I have a basic structure like this.
/model/function (admin/cat)
But what I need is to call another function from that 'cat', I know how to call another function, but I want my URL to look like this then.
/model/function1/function2 (admin/cat/add || admin/cat/delete etc...)
How can I do this?
Upvotes: 0
Views: 2270
Reputation: 695
So I'm not sure what the model has to do this with...
But I think what you're asking is you want a url structure like
/admin/cat/param
then your Controller should look like this
<?php
class Admin extends CI_Controller {
function cat($passed_in_param1)
{
if ($passed_in_param1 == 'add') {
// add a new category here
}
elseif ($passed_in_param1 == 'del') {
// del category here
}
}
}
?>
Upvotes: 0
Reputation: 27770
Either use routing or create a 'cat' controller in an 'admin' folder.
Upvotes: 2
Reputation: 2281
you can pass the name of the function as an argument to your cat
function, like this
function cat($func=''){
//call the function passed as an argument
if ($func && function_exists($func))
$this->$func();
}
Upvotes: 1