简体   繁体   中英

Loading the content of a static block from inside a magento CMS layout?

How would one load the content of a Magento static block inside a CMS layout?

My goal is to load the static block {{block type="cms/block" block_id=" menu_about "}} inside the layout, cannot find on how to do this who can help me? thank you!

    <!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>
<div class="menu_left col-lg-4 col-md-4">
    <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('menu_about')->toHtml(); ?> 
</div>

You can do the same for page if you want to. Customize block id to your desire.

 // 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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM