Magento将静态块加载到php文件中


Magento Load static block into php file

我创建了一个加载到iframe上的自定义表单。它还有send.php表单,这也是一个自定义文件。不过,我需要一条感谢消息,从静态块加载内容,这样客户端就可以更改它

如何将静态块中的文本加载到自定义php文件中?

感谢

试试这个:

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();

{BLOCK_IDENTIFIER}是静态块的id:

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

如果它能帮助其他,我会使用以下内容

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();