I'm trying to move the static CMS block from the category view into the sidebar. In my themename/template/catalog/category/view.phtml it is called with


Since it's defined as

   * Retrieve current category model object
   * @return Mage_Catalog_Model_Category
  public function getCurrentCategory()
      if (!$this->hasData('current_category')) {
          $this->setData('current_category', Mage::registry('current_category'));
      return $this->getData('current_category');

  public function getCmsBlockHtml()
      if (!$this->getData('cms_block_html')) {
          $html = $this->getLayout()->createBlock('cms/block')
          $this->setData('cms_block_html', $html);
      return $this->getData('cms_block_html');

I've tried adding this:

echo $this->getLayout()->createBlock('cms/block')->setBlockId(   $this->getCurrentCategory()->getLandingPage()    )->toHtml()

into my themename/template/callout/left-col.phtml file, but this throws errors.

How do I make it work?


Well, the getCurrentCategory() method is defined in the category view block Mage_Catalog_Block_Category_View, thus the left-col.phtml template doesn't have any refference to it. So instead of calling getCurrentCategory() method to get the category, you can get it from the registry: Mage::registry('current_category')

So, you can try changing your code to this:

echo $this->getLayout()->createBlock('cms/block')->setBlockId( Mage::registry('current_category')->getLandingPage() )->toHtml()

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.