user2607179
user2607179

Reputation: 95

Magento Load static block into php file

I have created a custom form that loads on an iframe. It also has the send.php form which is a custom file also. I need as a thank you message though to load the content from a static block so client can change it.

How can I load the text from the static block into a custom php file?

Thank you

Upvotes: 4

Views: 17508

Answers (3)

Muhammad
Muhammad

Reputation: 11

I used the following if it helps someone else

require_once ($_SERVER["DOCUMENT_ROOT"] . "/dev/app/Mage.php"); //remove dev if you want the Mage.php from root

  echo Mage::app()->getLayout()->createBlock('cms/block')>setBlockId('some_block_id')->toHtml();

Upvotes: 1

Marius
Marius

Reputation: 15206

Try this:

require_once 'path/to/'.'Mage.php'; //replace 'path/to' with the relative path to your Mage.app file
echo Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('some_block_id')->toHtml();

Upvotes: 14

RichardBernards
RichardBernards

Reputation: 3097

{BLOCK_IDENTIFIER} is the id of the static block:

echo Mage::getModel('cms/block')->load('{BLOCK_IDENTIFIER}')->getContent();

Upvotes: 6

Related Questions