簡體   English   中英

創建模塊prestashop 1.5

[英]Create module prestashop 1.5

我在PrestaShop 1.5 mau文件mymodule.php內容中創建了一個新模塊

 <?php
  if (!defined('_PS_VERSION_'))
   exit;
 
  class myModule extends Module
   {
    public function __construct()
     {
      $this->name = 'mymodule';
      $this->tab = 'Test';
      $this->version = 1.0;
      $this->author = 'Firstname Lastname';
      $this->need_instance = 0;
 
      parent::__construct();
 
      $this->displayName = $this->l('My module');
      $this->description = $this->l('Description of my module.');
     }
 
   public function install()
    {
    if (parent::install() == false)
      return false;
    return true;
    }
   public function uninstall()
    {
    if (!parent::uninstall())

    parent::uninstall();
    }
   }
?>

但我有一個錯誤消息

mymodule(erreur de syntaxe dans /modules/mymodule/mymodule.php)mymodule(classe manquante dans /modules/mymodule/mymodule.php)

你能幫我嗎

當我更改頁面的編碼(在沒有BOM的UTF-8中編碼)時,這個問題就解決了。

你為該模塊創建一個config.xml文件? 另一件事...... prestashop中沒有“測試”選項卡。 將其更改為有效的選項卡屬性。 http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module此鏈接可以幫助您。

當您的類文件中只有語法錯誤時,通常會出現此錯誤。 Prestashop無法加載類文件,因此無法加載模塊

您可以嘗試在命令行中啟動php -l mymodule.php以檢測php文件中可能的語法錯誤

我會選擇類名與模塊名相同。

   class mymodule(){

不是myModule

你也寫過

  if (!parent::uninstall())
        parent::uninstall();

在意思是如果卸載有錯誤你強行卸載? 我想,最好是

   if(parent::uninstall())
          return false;
   return true;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM