2012-03-18 95 views
5

我希望在后端(在“design/adminhtml”下)重复使用某个前端UI元素。这主要包括重复使用模板(phtml)。但是,从后端引用前端布局句柄看起来会更好。 magento是否提供共享UI组件的位置,将它们声明为共享的方式,还是通过前端/ adminhtml鸿沟引用它们的机制?谢谢在magento的前端和后端(admin或adminhtml)之间共享模板

回答

9

@coriscus 是的,这是可能的。我发现你使用admin的前端模板的技巧。

public function __construct() 
{ 
    parent::__construct(); 
    $this->setData('area','frontend'); 
    $this->setTemplate('customer/online.phtml'); 
} 

只需在块构造函数中设置需要的区域。

+0

谢谢!这是很有价值的帮助:以前的谷歌搜索很多都没有发现。 – coriscus 2012-03-19 17:24:47

+3

对于它的价值,为了完整性,对于像我这样的新手magento,这可以在layout-xml中以 \t <动作方法= “使用setData”> \t \t 区域 \t \t 前端 \t ',或更简单地说,如'<...块模板= “客户/ online.phtml”> \t < action method =“setArea”>前端 '其中* setArea('frontend')*与* setData('area','frontend')*的作用相同。 – coriscus 2012-03-20 17:56:13

+0

请注意,此方法将使用与当前管理软件包相同的设计软件包。在大多数情况下,它将是“默认”。 – 2014-05-27 09:07:57

相关问题