I want move static block landing in Category. I found code in file
/app/design/frontend/base/default/template/catalog/category/view.phtml
<?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 farSander Mangel– Sander Mangel2015年10月28日 14:28:12 +00:00Commented Oct 28, 2015 at 14:28
- 
 Reviced. I get error if I move all conditional instructions.ArturDvorak– ArturDvorak2015年10月28日 14:39:29 +00:00Commented Oct 28, 2015 at 14:39
2 Answers 2
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;?>
- 
 This one works immediately. +1. :)jehzlau– jehzlau2019年08月06日 05:16:02 +00:00Commented Aug 6, 2019 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
 <default>
 <reference name="root">
 <block type="core/template" name="category_static_block" template="page/html/category_static_block.phtml"/>
 </reference>
 </default>
Add the code below into your block
 <?php
 if (Mage::registry('current_category')):
 //get current category id
 $categoryId = Mage::registry('current_category')->getId();
 //load current category model
 $category = Mage::getModel('catalog/category')
 ->setStoreId(Mage::app()->getStore()->getId())
 ->load($categoryId);
 $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;
 endif;
 endif;
 ?>
And then echo this block out within your page template file:
<?php echo $this->getChildHtml('category_static_block');?>
- 
 I copied your code to 2columns-left.phtml and clear cache but it still does not work.ArturDvorak– ArturDvorak2015年10月29日 08:54:35 +00:00Commented Oct 29, 2015 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 answerBobadevv– Bobadevv2015年10月29日 09:10:37 +00:00Commented Oct 29, 2015 at 9:10
- 
 Ive updated my answer can you try the above and let me know if this works for youBobadevv– Bobadevv2015年10月29日 10:57:33 +00:00Commented Oct 29, 2015 at 10:57
- 
 code in local.xml put middle <config> ?ArturDvorak– ArturDvorak2015年10月29日 11:59:24 +00:00Commented Oct 29, 2015 at 11:59
- 
 no create a file local.xml and put this within your theme files under app/design/frontend/yourpackage/yourtheme/layoutBobadevv– Bobadevv2015年10月29日 12:09:08 +00:00Commented Oct 29, 2015 at 12:09