如何在CMS布局中加载Magento静态块的内容?
我的目标是加载静态块 {{block type =“cms / block”block_id =“ menu_about ”}}里面的布局,找不到怎么做这个谁可以帮帮我?谢谢!
<!DOCTYPE html>
<html lang="en">
<head>
<?php echo $this->getChildHtml('head') ?>
</head>
<body<?php echo $this->getBodyClass() ? ' class="' . $this->getBodyClass() . '"' : '' ?>>
<div class="wrapper">
STATIC LEFT CMS
<div class="wrapper_header">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('header') ?>
</div>
<div class="container">
<div class="menu_left col-lg-4 col-md-4">
{{block type="cms/block" block_id="menu_about"}}
</div>
<div class="col-lg-8 col-md-8">
<?php echo $this->getChildHtml('content') ?>
</div>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
<div class="menu_left col-lg-4 col-md-4">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu_about')->toHtml(); ?>
</div>
答案 1 :(得分:0)
如果您愿意,可以对页面执行相同操作。 根据您的需要自定义块ID。
// Insert the block into the page.
$sBlockId = 'changeme!';
$oBlock = Mage::getModel( 'cms/block' );
$oBlock->setStoreId( Mage::app()->getStore()->getId() );
$oBlock->load( $sBlockId, 'identifier' );
$oCmsHelper = Mage::helper( 'cms' );
$oProcessor = $oCmsHelper->getPageTemplateProcessor();
$sHtml = $oProcessor->filter( $oBlock->getContent() );
echo $sHtml;