how to create custom breadcrumb widget in yii framework

To make a custom breadcrumb in yii framework, try this step :

  1. we must create a new file BreadCrumb.php in your project folder, example :
    my-project\protected\components\BreadCrumb.php. And insert this code into the BreadCrumb.php file :

    class BreadCrumb extends CWidget {
         public $crumbs = array();
         public $delimiter = ' / ';
         public function run() {
  2. then create a new folder views in : my-project\protected\components\.

  3. make a new file breadCrumb_view.php in my-project\protected\components\views and insert this code to breadCrumb_view.php.

    <ul class="breadcrumb">
         foreach($this->crumbs as $crumb) {
            if(isset($crumb['url'])) {
                echo "<li>".CHtml::link($crumb['name'], $crumb['url'])."</li>";
            } else {
                echo "<li>".$crumb['name']."</li>";
            if(next($this->crumbs)) {
                echo $this->delimiter;

    in this example i use ul html tag for the breadcrumb. you can change the ul and li html tag to another html tag.

  4. and then you can use the breadcrumb in your view with insert this code :
    	$this->widget('application.components.BreadCrumb', array(
    	  'crumbs' => array(
    	    array('name' => 'Home', 'url' => array('site/index')),
    	    array('name' => 'Login'),
    	  'delimiter' => '&nbsp;', // if you want to change it

    and you can custom your delimiter in your breadcrumb.


if you have a question you can leave the message in this post 🙂


Easy installing for Yii Framework

I have been working with yii framework in one year. But i think it’s very easy to install and to use it. And what make me surprise in yii framework is a generator for CRUD.

This is the step of yii installation, it’s very easy (i use Windows 7 OS) :

Step 1 : Download yii framework in :

Step 2 : Unzip yii framework in your workspace (ex: my workspace in c:\xampp\htdocs).  after that, you can rename it with yii.

Step 3 : Before you use the command line in windows OS, you must register the path of your PHP in : my computer->(right click)Properties -> advanced system setting -> (tab) advanced -> Environment variable -> in system variable choose Path, click edit, and add your PHP path and klik OK, ex: in my computer ‘c:\xampp\php\bin’

Step 4 : open the window command line (cmd) and go to the workspace, and run :

yii/framework/yiic webapp mywebapp

This will create a directory with name mywebapp

Step 5 :  Then we will configure your Yii application. Open your web application in directory C:xampp/htdocs/mywebapp/protected/config/main.php in your favourite text editor and make the following changes some configuration :

Enabled gii with Un-comment the ‘gii’ section in the ‘modules’ array.
Enabled clean urls with Un-comment the ‘urlManager’ section in the ‘components’ array.
Set up the database connection: if you want to use Mysql database,Un-comment the mysql configuration database and comment the sqlite database. Then change the database name, username and password for mysql database.
Set up the admin email contact: Update the ‘adminEmail’ parameter in the ‘params’ array.

Then run in your browser : http://localhost/mywebapp
That’s it, your first web application in yii framework has been installed, just in a few minutes.

And may be this tutorial can help you ^_^.
If you want to learn another tutorial, you can go to :