When its come to Mage::registry('current_category'); is a common question.

After searching several pages,stack exchange and stack overflow i feel to post this question as i am unable to find a solution for this.and willing to get some advice to get from the helping mind in the community.

I want to update different content for different category pages in my website.

I use this code to get the current category and define the footer contents.

I added this code in to my footer.phtml and echo the $footer_content

$current_category = Mage::registry('current_category')->getName();
if($current_category=='All Deals'){
    $footer_content ="Content #1";
if($current_category=='Food & Dining'){
    $footer_content ="Content #2";

this code segment always return the one value for different category pages. What is the issue i am facing,it will be great pleasure if some one can explain any possible suggestion to fix this issue.


It totally cache issue.In your system, their have strong caching. of footer section.You need to disable this case by using layout code or rewrite your block class.

In layout you need to set footer block cache life time null that case will disable for this section.

<reference name="footer">
    <action method="setCacheLifetime"><s>null</s></action>

Also for your coding there issue.

You need to fix this.

if(Mage::registry('current_category')): // to prevent the error rest of pages except category &product page
  $current_category = Mage::registry('current_category')->getName();
  if($current_category=='All Deals'){
      $footer_content ="Content #1";
  if($current_category=='Food & Dining'){
      $footer_content ="Content #2";
| improve this answer | |
  • I don't think this will work. your theory is right. But the layout update will not work as you intended – Rajeev K Tomy Oct 6 '15 at 7:25
  • why? Rajeev.. can you please explain – Amit Bera Oct 6 '15 at 7:27
  • @AmitBera i used the if condition also,but its not worked for me.o i remove the if condition. – Mujahidh Oct 6 '15 at 7:29
  • This if condition not mail villein.. main issue cache... You need to add layout code on at layout file. Then need to flush cache. – Amit Bera Oct 6 '15 at 7:31
  • @AmitBera the layout update will do setCacheLifetime('null') instead of setCacheLifetime(NULL). Both of these will have different behaviour. First one WILL NOT remove cache. Later one will do. – Rajeev K Tomy Oct 6 '15 at 7:32

The problem is not that it is returning the same value, the problem is that the footer block gets cached thus giving you the impression that it just returns the same value.


  1. One solution is to rewrite the footer block (app/code/core/Mage/Page/Block/Html/Footer.php) and add the current category as part of the cache key (getCacheKeyInfo())





class [Vendor]_[ModuleName]_Block_Page_Html_Footer extends Mage_Page_Block_Html_Footer
    $key = parent::getCacheKeyInfo();
    $category = Mage::registry('current_category');
    if ($category) {
        $key[] = 'CATEGORY_'.$category->getId()

    return $key;
  1. Another solution would be to move your block outside of the footer so it is not cached from that block. I would still suggest though that you implement some caching of the block which will mean you implementing something similar to the footer block anyway.
| improve this answer | |
  • thank you,How to perform first solution,Please give me some more clarification on this. – Mujahidh Oct 6 '15 at 7:26
  • I have edited my reply for you. – Smartie Oct 6 '15 at 7:32
  • Is it adding the current category to cache or removing? – Mujahidh Oct 6 '15 at 7:36
  • It is adding the current category to the cache key so the cache key will change for each category and therefore the output should change – Smartie Oct 6 '15 at 7:37
  • i have a little bit confuse about the folder of footer.php is it app/code/local/Vendor/ModuleName/Block/Page/Html? – Mujahidh Oct 6 '15 at 9:32

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.