未找到模块模板 - Prestashop
No template found for module - Prestashop
所以我创建了我的第一个自定义模块,但我在模板显示方面遇到了问题。我从这里开始(或多或少)遵循了教程,但是当我启用我的模块时,它显示 "No template found for module "。我的模块名称是 kamailchimp 所以在模块的文件夹中我有 kamailchimp.php 和以下代码
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
class Kamailchimp extends Module
{
public function __construct()
{
$this->name = 'kamailchimp';
$this->tab = 'front_office_features';
$this->version = '1.0.0';
$this->author = 'Kon Ang';
$this->ps_versions_compliancy = array(
'min' => '1.7.0.0',
'max' => _PS_VERSION_,
);
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('KA - Embedded Mailchimp Form');
$this->description = $this->l('This module will allow you to display your embedded mailchimp form');
$this->templateFile = 'module:kamailchimp/views/templates/hook/kamailchimp.tpl';
}
public function install()
{
return parent::install() &&
$this->registerHook('header') &&
$this->registerHook('displayHome');
}
public function uninstall()
{
return parent::uninstall();
}
public function hookDisplayHome($params)
{
return $this->display(__FILE__, $this->templateFile);
}
}
我的 kamailchimp.tpl 文件在 modules/kamailchimp/views/templates/hook 文件夹和 themes/PRS025/modules/kamailchimp/views/templates/hook 中。
谁能告诉我我做错了什么?
PS1.7
您正在混合调用模板的两种方式。
你可以这样做:
public function hookDisplayHome($params)
{
return $this->display(__FILE__, 'views/templates/hook/kamailchimp.tpl');
}
或者像这样:
public function hookDisplayHome($params)
{
return $this->fetch('module:kamailchimp/views/templates/hook/kamailchimp.tpl');
// return $this->fetch($this->templateFile); // Or like this as you set $this->templateFile at the beginning of your file
}
我建议您使用最后一种方法,因为这是 PrestaShop 1.7 中新的更好的方法
所以我创建了我的第一个自定义模块,但我在模板显示方面遇到了问题。我从这里开始(或多或少)遵循了教程,但是当我启用我的模块时,它显示 "No template found for module "。我的模块名称是 kamailchimp 所以在模块的文件夹中我有 kamailchimp.php 和以下代码
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
class Kamailchimp extends Module
{
public function __construct()
{
$this->name = 'kamailchimp';
$this->tab = 'front_office_features';
$this->version = '1.0.0';
$this->author = 'Kon Ang';
$this->ps_versions_compliancy = array(
'min' => '1.7.0.0',
'max' => _PS_VERSION_,
);
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('KA - Embedded Mailchimp Form');
$this->description = $this->l('This module will allow you to display your embedded mailchimp form');
$this->templateFile = 'module:kamailchimp/views/templates/hook/kamailchimp.tpl';
}
public function install()
{
return parent::install() &&
$this->registerHook('header') &&
$this->registerHook('displayHome');
}
public function uninstall()
{
return parent::uninstall();
}
public function hookDisplayHome($params)
{
return $this->display(__FILE__, $this->templateFile);
}
}
我的 kamailchimp.tpl 文件在 modules/kamailchimp/views/templates/hook 文件夹和 themes/PRS025/modules/kamailchimp/views/templates/hook 中。
谁能告诉我我做错了什么? PS1.7
您正在混合调用模板的两种方式。
你可以这样做:
public function hookDisplayHome($params)
{
return $this->display(__FILE__, 'views/templates/hook/kamailchimp.tpl');
}
或者像这样:
public function hookDisplayHome($params)
{
return $this->fetch('module:kamailchimp/views/templates/hook/kamailchimp.tpl');
// return $this->fetch($this->templateFile); // Or like this as you set $this->templateFile at the beginning of your file
}
我建议您使用最后一种方法,因为这是 PrestaShop 1.7 中新的更好的方法