从 magento CMS 布局中加载静态块的内容?
Loading the content of a static block from inside a magento CMS layout?
如何在 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>
如果需要,您可以对页面执行相同的操作。
根据您的需要自定义块 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;
<div class="menu_left col-lg-4 col-md-4">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu_about')->toHtml(); ?>
</div>
如何在 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>
如果需要,您可以对页面执行相同的操作。 根据您的需要自定义块 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;
<div class="menu_left col-lg-4 col-md-4">
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu_about')->toHtml(); ?>
</div>