8

in my Layouts default.ctp I have

<!--nocache-->
  <?php echo $this->Html->getCrumbs(' / ', 'Home'); ?>
<!--/nocache-->

Inside a view called rules.cpt I have

<!--nocache--><?php $this->Html->addCrumb('Rules', '/rules'); ?><!--/nocache-->

When first opening the (uncached) view, the breadcrumbs are rendered as wished. With every additional (cached) rendering, only Home is being displayed.

When removing the caching from the Controller

// public $cacheAction = array('home' => 120, 'rules'  => 36000);

everything works.

Why isn't addCrumb() being called? I tested to add <?php echo time(); ?> to the same nocache-block which works (i.e. is called on every page rendering).

Gundon
  • 2,081
  • 6
  • 28
  • 46
  • 1
    what version of cakephp are you using? – MarcDefiant Feb 14 '13 at 12:21
  • v2.3 - Thanks for the hint. I added a label regarding the version-info – Gundon Feb 14 '13 at 14:06
  • 1
    why would the crumbs have to be outside the caching in the first place? you cache the site, hence the site's links should also be cachable as they dont change. – mark Feb 17 '13 at 22:02
  • Thats a good point mark.. At first I misunderstood the cookbook and thought the breadcrumbs show the last X visited sites. Thats where I added the `no-cache`-flags. But as the displayed info is static, you are right. If you post that as answer, I will tick it as correct – Gundon Feb 17 '13 at 23:07

1 Answers1

2

The issues source seems to be the order of the calls being made.

In my initial version <?php echo $this->Html->getCrumbs(' / ', 'Home'); ?> was called before <?php $this->Html->addCrumb('Rules', '/rules'); ?> what works fine as long as the views are not being cached.

As soon as they are cached in only works addCrumb is being called before getCrumbs.

This only partly answers my question. Because getCrumbs is used in my layouts .ctp it is not possible to change the order.

I posted this as answer and not as note on my question, so that nobody gets the bounty for something which I already wrote in the question ;) If you can provide a solution to the remaining problem or know if this is a bug in Cake, I am happy to provide you with the bounty.

Gundon
  • 2,081
  • 6
  • 28
  • 46