php - 面包屑未添加到缓存 View 中

标签 php cakephp caching breadcrumbs cakephp-2.3

在我的布局 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/

相关文章:

facebook - cakephp facebook api, FB->api ('/me' ) 返回空值

php - 在无向图中查找路径

php - html php通过多个页面和内部表单传递变量

php - 在php中使用临时表执行多个查询

php - CakePhp 选择查询..使用 findall()

http - 为什么 Firefox 忽略缓存 header 并在刷新时重新验证?

php - 如何将远程图像复制到我的网站目录?

php - 如何在 PHP 脚本中使用 svn+ssh?

java - @Cacheable 带有 null 键

java - 使用 ImageIO 静态方法使用缓存