Twitter Bootstrap style Breadcrumbs

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>
3 1
4 followers
Viewed: 19 884 times
Version: 1.1
Category: How-tos
Written by: junaidatari
Last updated by: junaidatari
Created on: Feb 6, 2013
Last updated: 5 years ago
Update Article

Revisions

View all history

Related Articles