嗨,我是 prestashop 的新手,我尝试为 1.7 创建一个管理模块。我会创建一个新菜单来显示模板并管理我的数据库。
模块/mymodule/mymodule.php:
<?php
if (!defined('_PS_VERSION_'))
{
exit;
}
class MyModule extends Module
{
public function __construct()
{
$this->name = 'mymodule';
$this->tab = 'administration';
$this->version = '1.0.0';
$this->author = 'John doe';
$this->bootstrap = true;
parent::__construct();
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
$this->displayName = $this->l('Mon module');
$this->description = $this->l('On test la creation de module presta.');
}
public function install()
{
// Install Tabs
$tab = new Tab();
$tab->active = 1;
$tab->class_name = "MyModule";
$tab->module = 'mymodule';
$tab->name = array();
$tab->id_parent = (int)Tab::getIdFromClassName('SELL');
$tab->position = 3;
foreach ($lang as $l) {
$tab->name[$l['id_lang']] = $this->l('Mon module');
}
$tab->add();
if (!parent::install())
return false;
return true;
}
public function uninstall()
{
// Uninstall Tabs
$tab = new Tab((int)Tab::getIdFromClassName('Mymodule'));
$tab->delete();
// Uninstall Module
if (!parent::uninstall())
return false;
return true;
}
}
模块/mymodule/controller/admin/MyModuleController.php:
<?php
class MyModuleController extends ModuleAdminController
{
public function renderList() {
$this->content = $this->createTemplate('mymodule.tpl')->fetch();
return $this->content;
}
}
?>
模块/mymodule/views/templates/admin/mymodule.tpl:
{block name="page_title"}
{l s='Mon module'}
{/block}
<section >
<div>Hello world !</div>
</section>
我通过编译大量教程 1.7 / 1.6 创建了它,但安装失败。Prestashop 为我们提供了一个文档来创建第一个模块,但它并没有真正记录在案,我在互联网上没有发现任何真正有用的 1.7。
有什么帮助/建议吗?
谢谢
EDIT1:好的,安装正确,我的选项卡已创建,但是当我单击它时,它会调用“controller = MyModule”并且找不到模块控制器。就快结束了。