I'm working on CI controller, and have problem with achieving URL I want to get.
I want to achieve URL like:
/someclass/url1/$id/url2
class Someclass extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->model('classes');
}
function index()
{
$this->url1($id=null);
}
function url1($Id)
{
//code
}
function url2()
{
//code
}
}
Also you could use , $this->uri->segment()
from the URI class, its easier for me.
I'm writing it maybe somebody will need it.
$total_segments = count ( $this->uri->segment_array() );
if($total_segments=='2'){
// this is something site.com/controllname/products
}
else if($total_segments=='3'){
// this is something site.com/controllname/products/id
}
Such a noob question!
I've added 2nd parameter to the function and that made my answer.
Thanks for help!