-1

I have a block that displays a random review in the footer. But when the BLOCK_HTML cache is active it is cached and does not display a random review.

I added the block in the theme local.xml:

<?xml version="1.0"?>
<layout version="0.1.0">
  <default>
    <!-- other stuff-->
    <reference name="footer">
      <!-- other stuff-->
      <block type="core/template" template="custom/random-review.phtml" name="random_review">
        <action method="setCacheLifetime"><s>null</s></action>
        <!-- <action method="setCacheLifetime"><s>0</s></action> I tried both, and I know the diffrence -->
      </block>
      <!-- other stuff-->
    </reference>
    <!-- other stuff-->
  </default>
  <!-- other stuff-->
</layout>

The template itself is mostly irrelevant to this question But I tried this in /template/custom/random-review.phtml:

<?php
echo rand (0,10000);
// the real template that fetches the random review.

It is called in /template/page/html/footer.phtml:

<!-- other footer stuff -->
<?php echo $this->getChildHtml('random_review') ?>
<?php //echo $this->getChildHtml('random_review', false)  // Also doesn't work ?>
<!-- other footer stuff -->

What am I missing here? Why is this block being cached?

1 Answer 1

1

Most probably your block is not cached.
The footer block is cached.
And since the footer contains your block it appears like it's cached.

You will need to change the cache key of your footer block.

Here is how you can do it or move your block outside the footer.

5
  • Well that sounds logic. Couldn't I just turn the footer cache off as well? The footer isself is build of other blocks and doesn't do anything itself.
    – janw
    Commented Nov 28, 2014 at 9:58
  • 1
    I think you can disable the cache for footer in a similar way you do it for your block
    – Marius
    Commented Nov 28, 2014 at 10:04
  • @Marius please answer my question here is the link
    – don7
    Commented Nov 28, 2014 at 10:26
  • @don7, please don't spam to get attention. I saw your question and it just isn't very clear what you want.
    – janw
    Commented Nov 28, 2014 at 10:29
  • atleast they can say that everyone is looking at it but no one responding and I need to have the answer immediatly that is why Iam doing in this way
    – don7
    Commented Nov 28, 2014 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.