Media Informasi

Media Informasi harian terkini

  • Home
Home » PHP » create Bread crumb using Php

create Bread crumb using Php

  aditya    
Step #1:- Create Breadcrumb.php Below Php code used to create the Breadcrumb URLs. Put Breadcrumb.php file under "system/application/libraries" folder.

========================================================================
========================================================================

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Breadcrumb {
 private $breadcrumbs = array();
 private $_divider = '  ›  ';
 private $_tag_open = '<div id="breadcrumb">';
 private $_tag_close = '</div>';

 public function __construct($params = array()){
  if (count($params) > 0){
   $this->initialize($params);
  }

  log_message('debug', "Breadcrumb Class Initialized");
 }

 /**
  * Initialize Preferences
  *
  * @access public
  * @param array initialization parameters
  * @return void
  */
 private function initialize($params = array()){
  if (count($params) > 0){
   foreach ($params as $key => $val)
   {
    if (isset($this->{'_' . $key}))
    {
     $this->{'_' . $key} = $val;
    }
   }
  }
 }


 /**
  * Append crumb to stack
  *
  * @access public
  * @param string $title
  * @param string $href
  * @return void
  */
 function append_crumb($title, $href){
  // no title or href provided
  if (!$title OR !$href) return;
  // add to end
  $this->breadcrumbs[] = array('title' => $title, 'href' => $href);
 }


 /**
  * Prepend crumb to stack
  *
  * @access public
  * @param string $title
  * @param string $href
  * @return void
  */
 function prepend_crumb($title, $href){
  // no title or href provided
  if (!$title OR !$href) return;

  // add to start
  array_unshift($this->breadcrumbs, array('title' => $title, 'href' => $href));
 }

 

 /**
  * Generate breadcrumb
  *
  * @access public
  * @return string
  */
 function output(){
  // breadcrumb found
  if ($this->breadcrumbs) {

   // set output variable
   $output = $this->_tag_open;

   // add html to output
   foreach ($this->breadcrumbs as $key => $crumb) {

    // add divider
    if ($key) $output .= $this->_divider;

    // if last element
    if (end(array_keys($this->breadcrumbs)) == $key) {
     $output .= '<span>' . $crumb['title'] . '</span>';

     // else add link and divider
    } else {
     $output .= '<a href="' . $crumb['href'] . '">' . $crumb['title'] . '</a>';
    }
   }

   // return html
   return $output . $this->_tag_close . PHP_EOL;
  }

  // return blank string
  return '';
 }

}


========================================================================
========================================================================




Step #2:- Use Breadcrumb in Php Controller Load the Breadcrumb library $this->load->library('breadcrumb'); folder. append_crumb method is used to append the bread crumb items.



========================================================================
========================================================================

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

// business method
public function index(){  
  /* Bread crum */
  $this->breadcrumb->append_crumb('Home', base_url());
  $this->breadcrumb->append_crumb('Tutorials', base_url().'tutorials');  
  $this->breadcrumb->append_crumb('Spring Tutorial', base_url().'tutorials/spring-tutorials');  
  
}


========================================================================
========================================================================

Step #3:- Finish :) Enjoy the How to create breadcrumb using php codeigniter
breadcrumb using php codeigniter
Label: PHP

Arsip Blog

Popular Posts

  • Contoh soal dan pembahasan Kalkulus 1 Integral
  • Membuat Login Form dengan PHP [Level Multi User]
  • Vocaloid 2 Hatsune Miku Full [Free Download]
  • Cara Import Database Ke Phpmyadmin yang File Nya *.opt *.frm *.MYD *.MYI
  • Cara Membuat Program Olah Data Sederhana menggunakan Netbean
  • Cara Menggunakan SSH di Android
  • Tutorial Mencari BUGS Host , Website , Server
  • Resident Evil 6 (2013) Full Version Pc Game Download Full Crack Patch iso
  • After "Submit", redirect back to previous page php
  • Buat text bergerak segala arah

Label

  • Trik (49)
  • software (49)
  • Info (47)
  • PHP (47)
  • tutorial (27)
  • Website (24)
  • Belajar (23)
  • Java (12)
  • Algoritma (11)
  • games (11)
  • Teknologi (9)
  • SEO (8)
  • berita (8)
  • film (8)
  • Design (6)
  • database (5)
  • promo (2)

Pengunjung

About

SEO Starter is SEO and Mobile Friendy Blogger Template. Responsive Sesuai dengan Rekomendasi Google

Web Links

  • Blogger Platform
  • CMS WordPress
  • Facebook
  • Microblogging
  • Manchester United

Follow by Email

Subsribe to get post update from this blog in your email inbox.

Copyright © Media Informasi. All rights reserved. Template by Romeltea Media