├── README.md ├── config ├── breadcrumbs.php └── index.html ├── index.html └── libraries ├── Breadcrumbs.php └── index.html /README.md: -------------------------------------------------------------------------------- 1 | Breadcrumbs is an small library that helps your manage HTML breadcrumbs with CodeIgniter. 2 | __* No longer maintained__ 3 | 4 | ## Instalation 5 | 6 | * Put Breadcrumbs.php in application/library folder 7 | * Put breadcrumbs.php in application/config folder 8 | 9 | ## Example of use 10 | 11 | // load Breadcrumbs 12 | $this->load->library('breadcrumbs'); 13 | 14 | // add breadcrumbs 15 | $this->breadcrumbs->push('Section', '/section'); 16 | $this->breadcrumbs->push('Page', '/section/page'); 17 | 18 | // unshift crumb 19 | $this->breadcrumbs->unshift('Home', '/'); 20 | 21 | // output 22 | $this->breadcrumbs->show(); 23 | 24 | ## License 25 | 26 | Released under the MIT License, Copyright (c) 2012–ω Buti. 27 | -------------------------------------------------------------------------------- /config/breadcrumbs.php: -------------------------------------------------------------------------------- 1 | /'; 18 | $config['tag_open'] = ''; 20 | $config['crumb_open'] = '
  • '; 21 | $config['crumb_last_open'] = '
  • '; 22 | $config['crumb_close'] = '
  • '; 23 | 24 | 25 | /* End of file breadcrumbs.php */ 26 | /* Location: ./application/config/breadcrumbs.php */ -------------------------------------------------------------------------------- /config/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

    Directory access is forbidden.

    8 | 9 | 10 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

    Directory access is forbidden.

    8 | 9 | 10 | -------------------------------------------------------------------------------- /libraries/Breadcrumbs.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright Copyright (c) 2012, Buti 11 | * @link https://github.com/nobuti/codeigniter-breadcrumb 12 | */ 13 | class Breadcrumbs { 14 | 15 | /** 16 | * Breadcrumbs stack 17 | * 18 | */ 19 | private $breadcrumbs = array(); 20 | 21 | /** 22 | * Constructor 23 | * 24 | * @access public 25 | * 26 | */ 27 | public function __construct() 28 | { 29 | $this->ci =& get_instance(); 30 | // Load config file 31 | $this->ci->load->config('breadcrumbs'); 32 | // Get breadcrumbs display options 33 | $this->tag_open = $this->ci->config->item('tag_open'); 34 | $this->tag_close = $this->ci->config->item('tag_close'); 35 | $this->divider = $this->ci->config->item('divider'); 36 | $this->crumb_open = $this->ci->config->item('crumb_open'); 37 | $this->crumb_close = $this->ci->config->item('crumb_close'); 38 | $this->crumb_last_open = $this->ci->config->item('crumb_last_open'); 39 | $this->crumb_divider = $this->ci->config->item('crumb_divider'); 40 | 41 | log_message('debug', "Breadcrumbs Class Initialized"); 42 | } 43 | 44 | // -------------------------------------------------------------------- 45 | 46 | /** 47 | * Append crumb to stack 48 | * 49 | * @access public 50 | * @param string $page 51 | * @param string $href 52 | * @return void 53 | */ 54 | function push($page, $href) 55 | { 56 | // no page or href provided 57 | if (!$page OR !$href) return; 58 | 59 | // Prepend site url 60 | $href = site_url($href); 61 | 62 | // push breadcrumb 63 | $this->breadcrumbs[$href] = array('page' => $page, 'href' => $href); 64 | } 65 | 66 | // -------------------------------------------------------------------- 67 | 68 | /** 69 | * Prepend crumb to stack 70 | * 71 | * @access public 72 | * @param string $page 73 | * @param string $href 74 | * @return void 75 | */ 76 | function unshift($page, $href) 77 | { 78 | // no crumb provided 79 | if (!$page OR !$href) return; 80 | 81 | // Prepend site url 82 | $href = site_url($href); 83 | 84 | // add at firts 85 | array_unshift($this->breadcrumbs, array('page' => $page, 'href' => $href)); 86 | } 87 | 88 | // -------------------------------------------------------------------- 89 | 90 | /** 91 | * Generate breadcrumb 92 | * 93 | * @access public 94 | * @return string 95 | */ 96 | function show() 97 | { 98 | if ($this->breadcrumbs) { 99 | 100 | // set output variable 101 | $output = $this->tag_open; 102 | 103 | // construct output 104 | foreach ($this->breadcrumbs as $key => $crumb) { 105 | $keys = array_keys($this->breadcrumbs); 106 | if (end($keys) == $key) { 107 | $output .= $this->crumb_last_open . '' . $crumb['page'] . '' . $this->crumb_close; 108 | } else { 109 | $output .= $this->crumb_open.'' . $crumb['page'] . ' '.$this->crumb_divider.$this->crumb_close; 110 | } 111 | } 112 | 113 | // return output 114 | return $output . $this->tag_close . PHP_EOL; 115 | } 116 | 117 | // no crumbs 118 | return ''; 119 | } 120 | 121 | } 122 | // END Breadcrumbs Class 123 | 124 | /* End of file Breadcrumbs.php */ 125 | /* Location: ./application/libraries/Breadcrumbs.php */ 126 | -------------------------------------------------------------------------------- /libraries/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

    Directory access is forbidden.

    8 | 9 | 10 | --------------------------------------------------------------------------------