Home » Php » php – Remove 'home' link from breadcrumb

php – Remove 'home' link from breadcrumb

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have breadcrumbs such as Home > Instance > Action in all my view pages. How can I remove the ‘Home’ link from all the breadcrumbs?

$this->breadcrumbs=array(
'Keypairs'=>array('admin'),
'Manage',
);
How to&Answers:

This can be done by setting the homeLink property to false, in your CBreadcrumbs widget initialization. This is usually done in a layout file.

In the default Yii app, in protected/views/layouts/main.php:

<?php if(isset($this->breadcrumbs)):?>
    <?php $this->widget('zii.widgets.CBreadcrumbs', array(
        'links'=>$this->breadcrumbs,
        'homeLink'=>false // add this line
    )); ?><!-- breadcrumbs -->
<?php endif?>

Answer:

in layouts/main.php add ‘homeLink’ => false

<?= Breadcrumbs::widget([
     'links' => isset($this->params['breadcrumbs'])? $this->params['breadcrumbs'] : [],
     'homeLink' => false
]) ?>