简体   繁体   English

addCrumb()对我不起作用cakePHP吗?

[英]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: 我有addCrumb()方法的问题,当我使用getCrumbs()时,它对我不起作用,但一切都很好,但是对于addCrumb()方法,我的视图中未显示任何内容,我在AppView中加载了HTML助手, CakePHP书中的所有内容,但我仍然看不到面包屑痕迹,这是我的代码示例:

<?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, 然后是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
]);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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