简体   繁体   中英

addCrumb() doesn't work for me cakePHP?

I have problem with addCrumb() method it doesn't work for me when I use getCrumbs() everything is fine but with addCrumb() method I don't get anything shown in my view I load HTML helper in my AppView and I did everything by CakePHP book but I still don't get breadcrumb trails this is my code sample:

<?php echo $this->Html->getCrumbs('>', [
    'text'=>$this->Html->image('home.png',['alt'=>'Home','height'=>50,'width'=>50]),
    'url'=>['controller'=>'Pages','action'=>'display','home'],
    'escape'=>false
]);
$this->Html->addCrumb('Users','/users');
$this->Html->addCrumb('Add User',['controller'=>'Users','action'=>'add']); ?>
?>

I also got confused looking at cake documentation at first. But later I figured it out.

The order of your code is wrong. First you have to do

$this->Html->addCrumb('Users','/users');
$this->Html->addCrumb('Add User',['controller'=>'Users','action'=>'add

Then the getCrumbs,

echo $this->Html->getCrumbs('>', [
'text'=>$this->Html->image('home.png',['alt'=>'Home','height'=>50,'width'=>50]),
'url'=>['controller'=>'Pages','action'=>'display','home'],
'escape'=>false
]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM