Uri Parameters in Controller in Bonfire


You can pass the values in the url in bonfire.
Suppose you have a url like
www.example.com/admin/custom/edit/3

where 3 is the primary id for the account you want to edit. You want to access the parameter 3 passed in the url.

For this place the following code in the edit() function of the ‘custom’ controller.

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class custom extends Admin_Controller {

    public function __construct()
    {
        parent::__construct();
    }
    public function edit()
    {
        $account_id =  $this->uri->segment(4);
    }
   
}

Here ‘4’ is the url segment which contains the value ‘3’. The segment counting starts after the base url. So
$this->uri->segment(1);   would represent ‘admin’.