love to get some help on this one as I'm stuck!

I have created some phtml files under app\design\frontend\mytheme\default\template\mytheme\

These phtml files pull data from static blocks in the backend using

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('my_static_block')->toHtml(); ?>

I then call the phtml files in my local.xml file e.g:

    <reference name="footer">
        <block type="page/html" name="my.block" template="mytheme/myblock.phtml"/>

Now the problem is this:

When caching is off everything works as it should and the blocks only display on the pages it should.

As soon as I enable caching the blocks then display on every page, when it shouldn't.

Any help would be appreciated!


I think I've explained this a few times.
The footer is cached independent of the page you are on.
This is a good thing, because in most cases the footer is the same all over the website.
But in your case it does not work.
You have 3 options here.

  1. The least pleasant one: Disable cache for the footer. Just rewrite the footer block and make its cache lifetime false.
  2. The easiest one: Instead of the footer use before_body_end block. That one is not cached. So your code could look like this:

        <reference name="before_body_end">
            <block type="page/html" name="my.block" template="mytheme/myblock.phtml"/>

    Sometimes this may not fit your needs either, because you may want your block somewhere between the footer elements. You can always reposition your block via javascript but it's ugly.

  3. The long but clean solution: Change the cache key for your footer block to take into account your specific page and create a different footer for that one. Here is an example on how you can do that.
  • Thanks for clearing that up! I think changing the reference to before_body_end should work fine for me :) – gj87 Oct 21 '14 at 6:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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