I wish to reuse a certain frontend UI element on the backend (under "design/adminhtml"). This would mostly consist of reusing the template (phtml). However, referencing the frontend layout handle from the backend would seem even better. Does magento provide a location for shared UI components, a way to declare them as shared, or a mechanism for referencing them across the frontend/adminhtml divide? Thanks
1 Answer
@coriscus Yes that is possible. I found the trick you use frontend template from admin.
public function __construct()
{
parent::__construct();
$this->setData('area','frontend');
$this->setTemplate('customer/online.phtml');
}
just set needed area in block constructor.
-
Thanks! This was valuable help: a lot of prior googling turned up nothing.– coriscusMar 19, 2012 at 17:24
-
3For what it's worth, for completeness, and for those, like myself, who are new to magento, this can be accomplished in layout-xml as
<block... template="customer/online.phtml"> <action method="setData"> <key>area</key> <value>frontend</value> </action> </block>
or, more briefly, as<block... template="customer/online.phtml"> <action method="setArea"><params>frontend</params></action> </block>
where setArea('frontend') does the same as setData('area', 'frontend').– coriscusMar 20, 2012 at 17:56 -
Be aware, that this method will use the same design package, as current admin package. In most of the cases it will be "default". May 27, 2014 at 9:07