[英]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();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.