在magento中在前端和后端(admin或adminhtml)之间共享模板

cor*_*cus 5 magento layout-xml

我希望在后端重用某个前端UI元素(在"design/adminhtml"下).这主要包括重用模板(phtml).但是,从后端引用前端布局句柄似乎更好.magento是否为共享UI组件提供了一个位置,一种将它们声明为共享的方式,或者是一种在前端/ adminhtml鸿沟中引用它们的机制?谢谢

Ser*_*gey 9

@coriscus是的,这是可能的.我找到了你使用管理员前端模板的技巧.

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

只需在块构造函数中设置所需的区域.

  • 对于完整性以及对于那些刚接触magento的人来说,这可以在layout-xml中实现为`<block ... template ="customer/online.phtml"> <action method = "setData"> <key> area </ key> <value> frontend </ value> </ action> </ block>`或者更简单地称为"<block ... template ="customer/online.phtml" > <action method ="setArea"> <params> frontend </ params> </ action> </ block>`其中*setArea('frontend')*与*setData('area','frontend')相同*. (3认同)