Good day! On the page I bring out breadcrumbs using the Breadcrumbs widget, according to the design, the text link to the main one should be replaced with a picture-link to the main one.

How can this be implemented using this widget?

Just in the documentation did not find something.

Thanks a lot in advance!

    1 answer 1

    You can extend the class of the standard widget, if we are talking about the first yii, then this is the CBreadcrumbs class. If you look at the class, then there is the homeLink attribute, here is the standard code

    /** * Renders the content of the portlet. */ 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); elseif($this->homeLink!==false) $links[]=$this->homeLink; foreach($this->links as $label=>$url) { if(is_string($label) || is_array($url)) $links[]=strtr($this->activeLinkTemplate,array( '{url}'=>CHtml::normalizeUrl($url), '{label}'=>$this->encodeLabel ? CHtml::encode($label) : $label, )); else $links[]=str_replace('{label}',$this->encodeLabel ? CHtml::encode($url) : $url,$this->inactiveLinkTemplate); } echo implode($this->separator,$links); echo CHtml::closeTag($this->tagName); } 

    you just need in your class to override the creation of $ this-> homeLink

    In Yii2, the principle should be the same.

    • I apologize for not specifying right away, the project is on Yii2 - Rumato
    • The principle there is the same as the option it can help you github.com/yiisoft/yii2/issues/6106 - Connor Holt