Search code examples
codeignitermodel-view-controllerbreadcrumbs

breadcrumbs in codeigniter (MVC)


I want some help with breadcrumb in codeigniter. It's my first experience with CodeIgniter and I don't have to clear enough how can I declare this function at Controller

public function breadcrumb(){
    $this->load->library('breadcrumb');

    function Tutorial() {
        parent::Controller();
        $this->load->library('breadcrumbcomponent');
        $this->breadcrumbcomponent->add('Home', base_url());
        $this->breadcrumbcomponent->add('Tutorials', base_url().'tutorials');       
        $this->breadcrumbcomponent->add('Spring Tutorial',   base_url().'tutorials/spring-tutorials');
    }   

}

in View. I create the library as it is showing here: http://www.technicalkeeda.com/codeigniter-tutorials/how-to-create-bread-crumb-using-php-codeigniter

Help me to understand better and to solve this case! Best :)


Solution

  • Please edit your question and include proper code tags where needed. I will assume that you are using new version of CodeIgniter, but old tutorial (one that is related to CI version less than 2). Try to change this in code should be working that way. In controller, change this code:

    function Tutorial(){
        parent::Controller();
        $this->load->library('breadcrumbcomponent');
    }
    

    with this one:

    public function __construct()
    {
        parent::__construct();
        $this->load->library('breadcrumbcomponent');
    }
    

    Library class could stay the same, I'd say.