Developer's Guide
there's only one such file, it is good practice to give it the same name as
the folder and main file: mymodule.tpl.
The mymodule.php file must start with the following test:
if ( !defined( '_PS_VERSION_' ) )
exit;
This checks for the existence of a PHP constant, and if it doesn't exist, it
quits. The sole purpose of this is to prevent visitors to load this file
directly.
The file must also contain the module's class. PrestaShop uses Object-
Oriented programming, and so do its modules.
That class must bear the same name as the module and its folder, in
CamelCase: MyModule.
Furthermore, that class must extend the Module class, and thus inherits all
methods and attributes. It can just as well extend any class derived from
Module: PaymentModule, ModuleGridEngine, ModuleGraph...
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;
}
}
?>
Let's examine each line from our MyModule object...