Yii 1.1: Twitter Bootstrap style Breadcrumbs

4 followers

1: Create breadcrumb in your view file.

$this->breadcrumbs=array(
    'Junaid Atari'=>array('user/main', 'id'=>12),
    'Change Password',
);

2: Update the code in /layouts/main.php

<?php if(isset($this->breadcrumbs)):
 
    if ( Yii::app()->controller->route !== 'site/index' )
        $this->breadcrumbs = array_merge(array (Yii::t('zii','Home')=>Yii::app()->homeUrl), $this->breadcrumbs);
 
    $this->widget('zii.widgets.CBreadcrumbs', array(
        'links'=>$this->breadcrumbs,
        'homeLink'=>false,
        'tagName'=>'ul',
        'separator'=>'',
        'activeLinkTemplate'=>'<li><a href="{url}">{label}</a> <span class="divider">/</span></li>',
        'inactiveLinkTemplate'=>'<li><span>{label}</span></li>',
        'htmlOptions'=>array ('class'=>'breadcrumb')
    )); ?><!-- breadcrumbs -->
    <?php endif; ?>

will generate twitter bootstrap styled breadcrumb code:

<ul class="breadcrumb">
    <li><a href="site/index">Home</a> <span class="divider">/</span></li>
    <li><a href="user/main/id/12">Junaid Atari</a> <span class="divider">/</span></li>
    <li><span>Change Password</span></li>
</ul>

Be the first person to leave a comment

Please to leave your comment.

Write new article