php - 客户注册表模板在站点主页上不起作用
问题描述
我正在尝试在我的主页上调用 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();
解决方案
使用模板文件时,将“.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" />
推荐阅读
- oracle - Team Foundation Server(或 Azure DevOps Server)是否与 Oracle SSO IAM 兼容?
- typescript - 当使用扩展时,TypeScript 可以在 switch 块中推断出正确的类型,就像我在使用联合时一样吗?
- c++ - 使用 gstreamer 重新采样和卸载音频 rtp
- entity-framework - 包含另一个类的字段
- vb.net - 组合框在表单加载事件中选择第一个项目。我如何更改它在表单加载时不选择第一个项目
- sql - 如何使用每周汇总的另一个表中的值创建一个临时表?
- spring-boot - springboot 2.1.2 log4j2 日志文件未创建
- javascript - 这是对 JS array.find 的错误使用还是要忽略的 VSCode 警告?
- javascript - 在 Javascript 中,声明式编码的幕后仍然是必要的吗?
- collections - Blueprism - 将网页中的数据提取到集合中