Breadcrumb for Codeigniter 3

Breadcrumb for Codeigniter 3


Published at - Aug 13, 2021

Demo – https://demo.domprojects.com/ci-breadcrumb/

Installation

  1. Download CodeIgniter 3.x.x
  2. Unpack the archive
  3. Copy the contents of the uncompressed archive to the root of your site or copy the directory of the uncompressed archive to the root of your site
./
|_ application
|_ system
|_ index.php

OR

./
|_ CI-Breadcrumb
  |_ application
  |_ system
  |_ index.php

Librairie CI-Breadcrumb

  1. Download the archive
  2. Unpack the archive
  3. Copy the contents of the uncompressed archive to your site
./
|_ application
  |_ controllers
    |_ Test_breadcrumb.php
  |_ libraries
    |_ Breadcrumb.php
  |_ views
    |_ test_breadcrumb.php
|_ system
|_ index.php

OR

./
|_ CI-Breadcrumb
  |_ application
    |_ controllers
      |_ Test_breadcrumb.php
    |_ libraries
      |_ Breadcrumb.php
    |_ views
      |_ test_breadcrumb.php
  |_ system
  |_ index.php

Utilisation

Folder controllers

Your controller file contents with the default style:

// Load library breadcrumb
$this->load->library('breadcrumb');

// Add items
$breadcrumb_items = [
  'Dashboard' => '/',
  'Users' => 'users',
  'Add' => 'users/add'
];
$this->breadcrumb->add_item($breadcrumb_items);

// Generate breadcrumb
$this->data['content_breadcrumb'] = $this->breadcrumb->generate();

With a style customization (for the example with Bootstrap):

// Load library breadcrumb
$this->load->library('breadcrumb');

// Custom style
$template = [
  'tag_open' => '<ol class="breadcrumb">',
  'crumb_open' => '<li class="breadcrumb-item">',
  'crumb_active' => '<li class="breadcrumb-item active" aria-current="page">'
];
$this->breadcrumb->set_template($template);

// Add items
$this->breadcrumb->add_item($breadcrumb_items);

// Generate breadcrumb
$data['breadcrumb_bootstrap_style'] = $this->breadcrumb->generate();

Folder views

File contents test_breadcrumb.php :

<?php echo $content_breadcrumb; ?>

Result

Default style (without style)

1. Dashbord
2. Users
3. Add

Bootstrap style

Dashbord / Users / Add


About author

Harendra
Harendra Kanojiya

Hi I'm Harendra Kumar Kanojiya. Currently I am FSD (Full-stack developer) and I have expertise with Angular ,PHP, Node JS, Laravel, Codeigniter and front end. Done few live projects and portfolio work in above.



Related Posts -

How to Set Dynamic Base Url in CodeIgniter
How to Set Dynamic Base Url ...

To set dynamic base_url in codeigniter 3 we need to follow steps given bel...



Follow Us

Follow us on facebook Click Here

Facebook QR
Scan from mobile
Join our telegram channel Click Here
Telegram QR
Scan from mobile