首页 > 解决方案 > 客户注册表模板在站点主页上不起作用

问题描述

我正在尝试在我的主页上调用 Magento 客户注册表单。当我在主页上调用它时,我尝试了两种方式,静态块或 template.phtml 文件,我的网站停止工作。任何人都可以向我提出解决方案吗?

<?php
echo $this->getLayout()->createBlock('cms/block')->setBlockId('register-form')->toHtml();

<?php
echo $this->getLayout()->createBlock('core/template')->setTemplate('persistent/customer/form/mini.register')->toHtml();

标签: phpmagentomagento-1.9

解决方案


使用模板文件时,将“.phtml”扩展名添加到文件名中。

在你的例子中:

echo $this->getLayout()->createBlock('core/template')->setTemplate('persistent/customer/form/mini.register.phtml')->toHtml();

请注意,上面的代码仅适用于模板文件。
如果您尝试通过 admin cms 页面将此添加到您的主页,那么您可以这样做:

{{ block type="core/template" template="persistent/customer/form/mini.register.phtml" }}

或通过布局文件:

<block type="core/template" template="persistent/customer/form/mini.register.phtml" />

推荐阅读