How to display a static block inside a modal in Magento CE 1.9?

1.7k Views Asked by At

As a front-end developer I have worked with several CMSs in the past, but I'm a Magento beginner.

I'd like to display the content of a static block inside a modal in Magento CE 1.9. I thought that would be pretty much easy to achieve, but I can't even seem to find an helpful tutorial on the web...

I don't want to use the Prototype based window.js that's included in the base package. I'd like to use a modal from a well-built, maintained and documented framework like Twitter Bootstrap 3 or Foundation 5 (Reveal).

Any help would be greatly appreciated as I don't even know where to start from.

Many thanks !

2

There are 2 best solutions below

0
On

As far as I understand, you've created a static block and you want to display it alongside the html/js codes right? If so, you can use the following code in your phtml file.

<?php
 echo $this->getLayout()->createBlock('cms/block')->setBlockId('my-static-block')->toHtml();
?>

Replace 'my-static-block' with the name of your static block.

0
On

I have practically called block in model class.i have made the method in model class.Am using session model class.

code:

mt-footer-bottom-1 is my block ID.that i am created in beckend.

public function getstaticContent(){

 $layout = Mage::getSingleton('core/layout');

// Generate a CMS block object
$block = $layout->createBlock('cms/block');

// Set the block ID of the static block
$block->setBlockId('mt-footer-bottom-1');

// Write the static block content to screen
echo $block->toHtml();

}