在prestashop中创建新的管理选项卡
这是我的密码。文件mymodule.php:在prestashop中创建新的管理选项卡,prestashop,Prestashop,这是我的密码。文件mymodule.php: class Mymodule extends Module { public function __construct() { $this->name = 'mymodule'; $this->tab = 'dashboard'; $this->version = '1.0'; $this->author = 'My Name'; $t
class Mymodule extends Module {
public function __construct() {
$this->name = 'mymodule';
$this->tab = 'dashboard';
$this->version = '1.0';
$this->author = 'My Name';
$this->need_instance = 0;
parent::__construct();
$this->displayName = $this->l('My Module');
$this->description = $this->l('My module description.');
$this->confirmUninstall = $this->l('Are you sure?');
}
public function install() {
return parent::install() &&
$this->installModuleTab('MyModuleController', 'My Tab', 13);
}
public function uninstall() {
return parent::uninstall() &&
$this->uninstallModuleTab('MyModuleController'));
}
private function installModuleTab($tabClass, $tabName, $idTabParent) {
$tab = new Tab();
foreach (Language::getLanguages() as $language) {
$tab->name[$language['id_lang']] = $tabName;
}
$tab->class_name = $tabClass;
$tab->module = $this->name;
$tab->id_parent = $idTabParent;
if (!$tab->save()) {
return false;
}
return true;
}
private function uninstallInternal($class_name) {
$idTab = Tab::getIdFromClassName($class_name);
if ($idTab != 0) {
$tab = new Tab($idTab);
$tab->delete();
return true;
}
return false;
}
}
文件MyModuleController.php:
class EraThemeController extends AdminController {
public function __construct() {
parent::__construct();
}
public function display() {
echo $this->l('This is my tab');
}
}
安装模块时,出现以下错误:
属性选项卡->名称为空
在文件classes/ObjectModel.php的第887行
重新加载管理页面时,已创建选项卡,但单击该选项卡时,出现错误:找不到控制器
有人能帮我吗?您的类应该定义为:
class AdminEraThemeController extends ModuleAdminController
另外,在您的模块主文件中,名称应为“AdminEraTheme”,而不是“MyModuleControl”我使用的是prestashop 1.7,在这个版本中,您自行声明$tabs和pretshaop on install and uninstall handle tabs,我在modules/module\u name/module\u name.php构造函数中添加了以下代码:
class Plevel extends Module
{
private $c_table='plevel';
private $c_table_pivot='plevel_excluded';
public function __construct()
{
$this->tabs = array(
array(
'name' => 'Price Level', // One name for all langs
'class_name' => 'AdminPLevel',
'visible' => true,
'icon'=>'money',
'parent_class_name'=>'DEFAULT_MTR'
),
array(
'name' => 'Price Level List', // One name for all langs
'class_name' => 'AdminPLevelList',
'visible' => true,
'parent_class_name'=>'AdminPLevel',
'icon'=>'setting',
));
$this->name="plevel";
$this->tab="dashboard";
$this->version="1.0.0";
$this->author="javaheri.ghazaleh@gmail.com";
$this->need_instance=0;
$this->ps_versions_compliancy=array('min'=>'1.6','max'=>_PS_VERSION_);
$this->bootstrap=true;
$this->context=Context::getContext();
$this->displayName=$this->l("plevel");
$this->description=$this->l("change order print page");
$this->confirmUninstall=$this->l('Are you sure you want to uninstall');
parent::__construct();
}}
我不久前读过一篇教程,可以帮助您: