Jump to content

mon 1er module prestashop


Recommended Posts

slt, voici le fichier monmodule.php:
<?php
<?php
class MyModule extends Module
{
public function __construct()
{
$this->name = 'mymodule';
$this->tab = 'Test';
$this->version = 1.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 install()
{
if(parent::install() == false) return false; return true;
}

public function uninstall()
{
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'block_cms` WHERE `id_block` ='.intval($this->id));
parent::uninstall();
}
}
?>

le fichier monmodule.tpl est pour le moment vide..!!

Link to comment
Share on other sites

Soit :

<?php
<?php
class MyModule extends Module
{
public function __construct()
{ $this->name = ‘mymodule’; $this->tab = ‘Test’; $this->version = 1.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 install()
{
if(parent::install() == false) return false; return true;
}

public function uninstall()
{ Db::getInstance()->Execute(‘DELETE FROM `’.DB_PREFIX.‘block_cms` WHERE `id_block` =’.intval($this->id)); parent::uninstall();
}
}
?>



Tu as 2 <?php et 2 fonctions Install(), c'est une erreur de copié / collé ?

Link to comment
Share on other sites

oui desolé:

<?php

class MyModule extends Module
{
public function __construct()
{
$this->name = 'mymodule';
$this->tab = 'Test';
$this->version = 1.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()
{
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'block_cms` WHERE `id_block` ='.intval($this->id));
parent::uninstall();
}
}
?>

Link to comment
Share on other sites

Tiens, voilà le contenu du module blockinfos dont tu peux t'inspirer :

class BlockInfos extends Module
{
   private $_html;

   public function __construct()
   {
       $this->name = 'blockinfos';
       $this->tab = 'Blocks';
       $this->version = 1.1;

       parent::__construct();

       $this->displayName = $this->l('Info block');
       $this->description = $this->l('Adds a block with several information links');
   }

   public function install()
   {
       if (!parent::install() OR !$this->registerHook('leftColumn'))
           return false;
       Db::getInstance()->Execute('
           INSERT INTO `'._DB_PREFIX_.'block_cms`(`id_block`, `id_cms`)
           VALUES
               ('.intval($this->id).', 1),
               ('.intval($this->id).', 2),
               ('.intval($this->id).', 3),
               ('.intval($this->id).', 4)');
       return true;
   }

   public function uninstall()
   {
       Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'block_cms` WHERE `id_block` ='.intval($this->id));
       return parent::uninstall();
   }

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...