I want move static block landing in Category. I found code in file


<?php elseif($this->isMixedMode()): ?>
<?php echo $this->getCmsBlockHtml() ?>
<?php echo $this->getProductListHtml() ?>

I tried copy or move <?php echo $this->getCmsBlockHtml() ?> in file 2columns-left.phtml but it does not work.

  • What exactly is not working? Please update your question with errors and what you have tried so far – Sander Mangel Oct 28 '15 at 14:28
  • Reviced. I get error if I move all conditional instructions. – ArturDvorak Oct 28 '15 at 14:39

Add bellow code in file 2columns-left.phtml

<?php if($currentCategory = Mage::registry('current_category')):?>
                <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId($currentCategory->getLandingPage())->toHtml();     
?><?php endif;?>
|improve this answer|||||
  • This one works immediately. +1. :) – jehzlau Aug 6 '19 at 5:16

The problem is you cannot use those methods outside of the category view.phtml file.

If you want to get a categories static block content outside of this file you can use the following I based this on the answer given here by Rajeev - how to get cms block value from display settings of a category

Create a new template block add the following to your local xml

        <reference name="root">
            <block type="core/template" name="category_static_block" template="page/html/category_static_block.phtml"/>

Add the code below into your block

        if (Mage::registry('current_category')):

            //get current category id
            $categoryId = Mage::registry('current_category')->getId();
            //load current category model
            $category = Mage::getModel('catalog/category')

            $mode = $category->getDisplayMode();
            //display mode = PAGE means, that category has a static block
            if ($mode == 'PAGE' || $mode == 'PRODUCTS_AND_PAGE'):
                //get static block id
                $page = $category->getLandingPage();

                //cms block
                $cms_block = Mage::getModel('cms/block')->load($page);

                //parse template to convert {{fields}}
                //from http://stackoverflow.com/a/5413698/156388
                $helper = Mage::helper('cms');
                $processor = $helper->getPageTemplateProcessor();
                $content = $processor->filter($cms_block->getContent());
                echo $content;


And then echo this block out within your page template file:

<?php echo $this->getChildHtml('category_static_block');?>
|improve this answer|||||
  • I copied your code to 2columns-left.phtml and clear cache but it still does not work. – ArturDvorak Oct 29 '15 at 8:54
  • Just realised I am using the code above in a core/template block not within a page template. Ill have a look and update my answer – Bobadevv Oct 29 '15 at 9:10
  • Ive updated my answer can you try the above and let me know if this works for you – Bobadevv Oct 29 '15 at 10:57
  • code in local.xml put middle <config> ? – ArturDvorak Oct 29 '15 at 11:59
  • no create a file local.xml and put this within your theme files under app/design/frontend/yourpackage/yourtheme/layout – Bobadevv Oct 29 '15 at 12:09

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.