简体   繁体   中英

Create module prestashop 1.5

I created a new module in PrestaShop 1.5 mau file mymodule.php content

 <?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();
    }
   }
?>

But i have an error msg

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

can you help me please

当我更改页面的编码(在没有BOM的UTF-8中编码)时,这个问题就解决了。

do you create a config.xml file for that module ?? and one another thing ... there is not " Test " tab in prestashop . change that to a valid tab attribute . http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module this link can help you .

This error often appears when there is just a syntax error in your class file. Prestashop can not load the class file, and so, cannot load the module

You can try to launch a php -l mymodule.php in command line to detect possible syntax error in the php file

I would choose class name to be same as module name.

   class mymodule(){

not myModule

Also you've written

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

in meaning if uninstall have errors you unninstall by force? I think, it's better to

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM