题
我想在前端调用两个phtml,即管理端phtml
是否可以在客户帐户中调用后端的phtml?
如果是,我想将这两个 phtml 称为:
adminhtml\default\default\template\downloadable/product/edit/downloadable/samples.phtml
adminhtml\default\default\template\downloadable/product/edit/downloadable/links.phtml
如何调用这个phtml?
解决方案
我认为,理论上你可以通过模拟前端区域的后端来做到这一点。您可以像这样进行仿真:
$adminStoreId = 0;
$appEmulation = Mage::getSingleton('core/app_emulation');
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($adminStoreId);
//your magic here
//then stop the emulation
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
但这不是一个好的做法。如果您提到的模板中有网址,那么它们将使用管理助手生成,最终您会感到紧张 key
范围。
更不用说它可能不适合您的设计。
我建议您将模板克隆到前端并将前端与后端分开。