网络营销电子商务研究中心  
USA Web Hosting Direct
Go Back   网络营销电子商务研究中心 > 网站建设 > Magento
User Name
Password
 
FAQ Members List Calendar 域名注册 PHP Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1   IP: 49.82.125.34
Old 2017-03-25, 12:40 PM
Adrien Adrien is offline
初级会员
 
Join Date: 2011-05-27
Posts: 2
Adrien 现在声名狼藉
Default Magento在代码中调用静态块(Static Block)

假设有在Magento后台建立一个Static Block名字为'footer_links',在phtml(其他php文件中方法一样)中调用方式如下:
Php代码  
// Block是与店铺相关的,所以要设置setStoreId.  
Code:
$block = Mage::getModel('cms/block')  
 ->setStoreId(Mage::app()->getStore()->getId())  
 ->load('footer_links');  
$content = $block->getContent(); // Block的原始内容已经获得  
  
$processor = Mage::getModel('core/email_template_filter');  
$html = $processor->filter($content);  
Mage::getModel('core/email_template_filter')->filter()是必须的,因为Static Block里可能包含Magento的模板语言(如:{{store url=""}}),fiter将翻译成实际的值
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
所有时间均为 +8. 现在的时间是 01:11 AM, Free Patent & Patent Ideas