2017-03-17 84 views
1

我正在嘗試prestashop 1.7,並且創建自定義模塊時遇到問題。 我創建了一個文件夾「MyModule的」「模塊」文件夾內,並且,因爲它是在文檔中表示,我創建了一個簡單mymodule.php文件吧:Prestashop 1.7無法顯示自定義模塊

<?php 

/* 
* To change this license header, choose License Headers in Project Properties. 
* To change this template file, choose Tools | Templates 
* and open the template in the editor. 
*/ 

if (!defined('_PS_VERSION_')) 
exit; 

class MyModule extends Module 
{ 
    public function __construct() 
    { 
    $this->name = 'mymodule'; 
    $this->tab = 'front_office_features'; 
    $this->version = '1.0.0'; 
    $this->author = 'Firstname Lastname'; 
    $this->need_instance = 0; 
    $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); 
    $this->bootstrap = true; 

    parent::__construct(); 

    $this->displayName = $this->l('My module'); 
    $this->description = $this->l('Description of my module.'); 

    $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); 

    if (!Configuration::get('MYMODULE_NAME'))  
     $this->warning = $this->l('No name provided'); 
    } 
} 

?> 

然後我去了管理頁面下的「模塊」 - >「模塊&服務」在「已安裝的模塊」選項卡上,但我找不到我的模塊...

我在做什麼錯誤?

感謝

澤維爾

+0

如果您尚未安裝該模塊,它將不會顯示在已安裝的模塊選項卡中。你應該在第一個標籤中找到它。另外,不要忘記添加安裝和卸載功能。 – sadlyblue

回答

5

你的步驟都沒事。 要提醒,創建一個「自定義」模塊中,我們應該做的:

  1. 創建模塊的文件夾,例如文件夾命名爲`mycustommodule`
  2. 創建一個名稱與文件夾類似的php文件,例如`mycustommodule.php`
  3. 那麼「引導」類(構建)應該是這樣的:
<?php 
if (!defined('_PS_VERSION_')) 
    exit; 

class MyCustomModule extends Module 
{ 
    public function __construct() 
    { 
     $this->name = 'mycustommodule'; /* This is the 'technic' name, this should equal to filename (mycustommodule.php) and the folder name */ 
     $this->tab = 'module type category'; /* administration, front_office_features, etc */ 
     $this->version = '1.0.0'; /* Your module version */ 
     $this->author = 'Firstname Lastname'; /* I guess it was clear */ 
     $this->need_instance = 0; /* If your module need an instance without installation */ 
     $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); /* Your compatibility with prestashop(s) version */ 
     $this->bootstrap = true; /* Since 1.6 the backoffice implements the twitter bootstrap */ 

     parent::__construct(); /* I need to explain that? */ 

     $this->displayName = $this->l('My module'); /* This is the name that merchant see */ 
     $this->description = $this->l('Description of my module.'); /* A short description of functionality of this module */ 

     $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); /* This is a popup message before the uninstalling of the module */ 
    } 
} 
?> 

隨後的Prestashop 1.7.xx你在Modules並在Selection選項卡中點擊進入在「類別」,找到你的模塊(記得$這個 - >標籤片段?)

Categories menu

否則,你可以通過搜索找到它:

Search input

相關問題