在我的布局 default.ctp 中有
<!--nocache-->
<?php echo $this->Html->getCrumbs(' / ', 'Home'); ?>
<!--/nocache-->
在名为 rules.cpt 的 View 中我有
<!--nocache--><?php $this->Html->addCrumb('Rules', '/rules'); ?><!--/nocache-->
当第一次打开(未缓存的) View 时,面包屑会按预期呈现。对于每个额外的(缓存的)渲染,只有 Home
正在显示。
当从 Controller 中移除缓存时
// public $cacheAction = array('home' => 120, 'rules' => 36000);
一切正常。
为什么不是 addCrumb()
被叫?我测试添加 <?php echo time(); ?>
同样nocache
-有效的 block (即在每个页面呈现时调用)。
最佳答案
问题来源似乎是调用的顺序。
在我的初始版本中 <?php echo $this->Html->getCrumbs(' / ', 'Home'); ?>
之前被调用过<?php $this->Html->addCrumb('Rules', '/rules'); ?>
只要 View 没有被缓存,什么就可以正常工作。
一旦它们被缓存在 only works addCrumb
中在之前被调用getCrumbs
.
这只是部分回答了我的问题。因为getCrumbs
在我的布局中使用 .ctp
无法更改顺序。
我将其发布为答案而不是我的问题的注释,这样就没有人会因为我已经在问题中写过的东西而得到赏金;)如果你能为剩下的问题提供解决方案或者知道这是否是 Cake 中的错误,我很乐意为您提供赏金。
关于php - 面包屑未添加到缓存 View 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14823148/