加载Magento模块模板 [英] Load Magento module template
问题描述
对于Magento模块,我需要加载模板文件并让其替换整个页面.它是一个XML文件(但也可以是任何内容). 一般来说
For a Magento module I need to load template file and let it replace the complete page. It is a XML file (but could also be any content whatsoever). Generally speaking when
MYNS_MYMODULE_controllernameController
被触发并调用fooAction()
,我需要能够显示一个干净的网站,其中包含模板文件中的内容.
MYNS_MYMODULE_controllernameController
is triggered and calls fooAction()
I need to be able to display a clean site with the content from my template file.
请让我知道模板文件的放置位置,以及如何告知Magento将此文件作为根模板加载,而无需其他操作.
Please let me know where to place the template file and how to tell Magento to load this file as a root template without anything else around.
编辑,以进一步阐明它:
Edit, to clarify it more:
对于 http://domain.tld/ 模块名称/控制器/操作/
我必须在哪里放置模板文件,如何引用它们?
Where do I have to place template files and how should I reference them?
推荐答案
您可以这样做
$this->loadLayout()->getLayout()->getBlock('root')->setTemplate('page/1column.phtml');
$this->renderLayout();
或设置自定义响应
//$file = myfile or html
$this->getResponse()->setBody($file);
$this->renderLayout();
理想情况下,您的模板应位于/app/design/frontend/mypackage/mytheme/template/mytemplate.phtml
Ideally your template should sit in /app/design/frontend/mypackage/mytheme/template/mytemplate.phtml
这篇关于加载Magento模块模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!