2011-02-15 65 views

回答

18

在模板:

<?php 
$filter = Mage::getModel('widget/template_filter'); 
echo $filter->filter('{{widget type="cms/widget_page_link" template="cms/widget/link/link_block.phtml" page_id="2"}}'); 
?> 
+0

大 - 抓住一个产品链接是:<?PHP $过滤=新Mage_Widget_Model_Template_Filter(); $ _widget = $ filter-> filter('{{widget type =“catalog/product_widget_link”template =“cms/widget/link/link_block.phtml”id_path =“product/16”}}'); echo $ _widget; ?> – 2011-02-15 21:51:29

+0

很高兴知道,删除我的答案。 – B00MER 2011-02-15 23:21:40

2

要知道正确的参数“类型”,“模板”多,你可以在一个块/页模板中使用的图形编辑器“插入控件”按钮,然后你点击显示/隐藏编辑器,你会得到代码

1

上面的答案可能会起作用,但同样的事情可以通过加载小部件来达到,就像使用静态块一样,并使用魔法设置器传入自定义参数像这样:

<?php echo $this->getLayout()->createBlock('cms/widget_page_link')->setTemplate('cms/widget/link/link_block.phtml')->setPageId(2); ?> 
5

安德鲁错过toHtml()结尾功能:

<?php echo $this->getLayout()->createBlock('cms/widget_page_link')->setTemplate('cms/widget/link/link_block.phtml')->setPageId(2)->toHtml(); ?>