Skip to main content
Variable data were not showing in static block content on frontend.
Source Link

Use this code to retrieve cms block details

$cat = Mage::getModel('catalog/category')->load(13);

$mode  = $cat->getDisplayMode();
//display mode = PAGE means, that category has a static block
if($mode == 'PAGE' || $mode == 'PAGE_AND_PRODUCTS'){
    //get static block id
    $page = $cat->getLandingPage();

    //cms block
    $cms_block = Mage::getModel('cms/block')->load($page);

    //retrieve cms block data
    $title = $cms_block->getTitle(); // title of cms block
    $identifier = $cms_block->getIdentifier(); //identifier for that cms block
    $content = $cms_block->getContent(); //get entire content of cms block

    $content_data= $this->getLayout()->createBlock('cms/block')->setBlockId($cms_block->getIdentifier())->toHtml(); // if you are using shortcodes/variables in static block.
}

The key point here is, the method getLandingPage() provides cms block id. Using this block id, we are then load cms block model and retrieves appropriate blocks information.

Hope that helps

Use this code to retrieve cms block details

$cat = Mage::getModel('catalog/category')->load(13);

$mode  = $cat->getDisplayMode();
//display mode = PAGE means, that category has a static block
if($mode == 'PAGE' || $mode == 'PAGE_AND_PRODUCTS'){
    //get static block id
    $page = $cat->getLandingPage();

    //cms block
    $cms_block = Mage::getModel('cms/block')->load($page);

    //retrieve cms block data
    $title = $cms_block->getTitle(); // title of cms block
    $identifier = $cms_block->getIdentifier(); //identifier for that cms block
    $content = $cms_block->getContent(); //get entire content of cms block

}

The key point here is, the method getLandingPage() provides cms block id. Using this block id, we are then load cms block model and retrieves appropriate blocks information.

Hope that helps

Use this code to retrieve cms block details

$cat = Mage::getModel('catalog/category')->load(13);

$mode  = $cat->getDisplayMode();
//display mode = PAGE means, that category has a static block
if($mode == 'PAGE' || $mode == 'PAGE_AND_PRODUCTS'){
    //get static block id
    $page = $cat->getLandingPage();

    //cms block
    $cms_block = Mage::getModel('cms/block')->load($page);

    //retrieve cms block data
    $title = $cms_block->getTitle(); // title of cms block
    $identifier = $cms_block->getIdentifier(); //identifier for that cms block
    $content = $cms_block->getContent(); //get entire content of cms block

    $content_data= $this->getLayout()->createBlock('cms/block')->setBlockId($cms_block->getIdentifier())->toHtml(); // if you are using shortcodes/variables in static block.
}

The key point here is, the method getLandingPage() provides cms block id. Using this block id, we are then load cms block model and retrieves appropriate blocks information.

Hope that helps

Source Link
Rajeev K Tomy
  • 17.3k
  • 6
  • 63
  • 103

Use this code to retrieve cms block details

$cat = Mage::getModel('catalog/category')->load(13);

$mode  = $cat->getDisplayMode();
//display mode = PAGE means, that category has a static block
if($mode == 'PAGE' || $mode == 'PAGE_AND_PRODUCTS'){
    //get static block id
    $page = $cat->getLandingPage();

    //cms block
    $cms_block = Mage::getModel('cms/block')->load($page);

    //retrieve cms block data
    $title = $cms_block->getTitle(); // title of cms block
    $identifier = $cms_block->getIdentifier(); //identifier for that cms block
    $content = $cms_block->getContent(); //get entire content of cms block

}

The key point here is, the method getLandingPage() provides cms block id. Using this block id, we are then load cms block model and retrieves appropriate blocks information.

Hope that helps