magento 静态块 static block 调用

在后台创建一个order_form静态块,内容分别如下:

Block Title: Order FormIdentifier: order_formStatus :EnabledContent :自定义内容


方法一:如果要在.phtml文件中直接调用这个静态块,那可以采用以下两种方法

1:

<?php$block = Mage::getModel(‘cms/block’)->setStoreId(Mage::app()->getStore()->getId())->load(‘order_form’);$content = $block->getContent(); // Block的原始内容已经获得$processor = Mage::getModel(‘core/email_template_filter’);echo $html = $processor->filter($content);?>

Mage::getModel(‘core/email_template_filter’)->filter()是必须的,因为Static Block里可能包含Magento的模板语言(如:{{store url=””}}),fiter将翻译成实际的值
Magento中调用静态Block主要有两个地方。
2:这代码太长了呢,那你还可以这么写

<?php echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘order_form’)->toHtml() ?>

方法二:如何在CMS页面的Content中调用这个静态块呢?你可以采用以下方法

{{block type="cms/block" block_id="order-form" template="cms/content.phtml"}}

方法三:怎么样在layout中调用静态块呢
首先先设置block相应的xml内容:

<reference name=”footer”> <block type=”cms/block” name=”order_form” before=”-”> <action method=”setBlockId”><block_id>order_form</block_id></action> </block></reference>

然后在相应在模板文件.phtml中调用

getChildHtml('order_form');


http://www.hicoogle.com/magento-static-block-static-block-calls.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值