Here is the code I modded. You can see the code I commented out. The regular text output works, but the one for the link does not.
<?php
class CBreadcrumbs extends CWidget
{
public $tagName='div';
public $htmlOptions=array('class'=>'breadcrumbs');
public $encodeLabel=true;
public $homeLink;
public $links=array();
public $separator='';
public function run()
{
if(empty($this->links))
return;
//echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
$links=array();
if($this->homeLink===null)
$links[]=CHtml::link(Yii::t('zii','Home'),Yii::app()->homeUrl);
else if($this->homeLink!==false)
$links[]=$this->homeLink;
foreach($this->links as $label=>$url)
{
if(is_string($label) || is_array($url))
$links[]='<li>'.CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url).'</li>';
else
$links[]='<li><a>'.($this->encodeLabel ? CHtml::encode($url) : $url).'</a></li>';
}
echo implode($this->separator,$links);
//echo CHtml::closeTag($this->tagName);
}
}
Outputs:
<ul class="breadcrumb">
<a href="/yii/mm_elite/index.php">Home</a>
<li><a>Contact</a></li>
</ul>
The <li> tags are being sent with the output. Any ideas.
andy_s:
Don’t modify core classes. Instead create your own Breadcrumbs class extending CBreadcrumbs and override it’s run() method.
What do you want to achieve actually?
I just need to modify the html output of the breadcrumbs. I need it to look like the following:
<ul class="breadcrumb">
<li><a href="/yii/mm_elite/index.php">Home</a></li>
<li><a>Contact</a></li>
</ul>
I have converted a the WhiteLabel Admin template to a Yii powered site and I am having some minor issues applying the css/jquery styling to the yii framework site.
dmadmc.com/yii/mm_elite/ <— Here is the progress this far.
Here is the link to the template and how the breadcrumbs are displayed:
revaxarts-themes.com/whitelabel/breadcrumb.html
weavora
(Yury Tolochko)
November 29, 2011, 5:48am
4
<?php
class CBreadcrumbs extends CWidget
{
public $tagName='div';
public $htmlOptions=array('class'=>'breadcrumbs');
public $encodeLabel=true;
public $homeLink;
public $links=array();
public $separator='';
public function run()
{
if(empty($this->links))
return;
//echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n";
$links=array();
if($this->homeLink===null)
$links[]='<li>'.CHtml::link(Yii::t('zii','Home'),Yii::app()->homeUrl).'</li>';
else if($this->homeLink!==false)
$links[]='<li><a>'.$this->homeLink.'</a></li>';
foreach($this->links as $label=>$url)
{
if(is_string($label) || is_array($url))
$links[]='<li>'.CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url).'</li>';
else
$links[]='<li><a>'.($this->encodeLabel ? CHtml::encode($url) : $url).'</a></li>';
}
echo implode($this->separator,$links);
//echo CHtml::closeTag($this->tagName);
}
}
This should work fine for you… You’ve missed home link (before foreach)