-
Notifications
You must be signed in to change notification settings - Fork 1
How to create a module
-
Create your module in directory "modules"
-
make directories : boxe, class, config, image, js, lang, lib, template
-
create a config/config.php file
-
Declare the Id card of the module like this Ex : The companion Module
$conf->modules['companion']=array( 'name'=>'companion' /* name */ ,'id'=>'TCompanion' /* key */ ,'class'=>array('TCompanion') /* contain the name of the différentes classes in the module */ ,'moduleRequire'=>array('core') /* dependency */ );
-
Add hook
TAtomic::addHook($conf , array('Notify','TProduct','Home') // where ,array( 'function'=>'hook' // function to call ,'object'=>'TCompanion' // in object ,'parameters'=>array() ) );
-
Add menus
TTemplate::addMenu($conf, 'TCompany', 'Companies', HTTP.'modules/company/company.php', 'company', '', false, 1);
-
Add tabs in page module
TTemplate::addTabs($conf,'TCompany',array( 'card'=>array('label'=>'__tr(Card)__','url'=>HTTP.'modules/company/company.php?action=view&id=@id@') ,'contact'=>array('label'=>'__tr(Contact)__','url'=>HTTP.'modules/contact/contact.php?id_company=@id@') ,'address'=>array('label'=>'__tr(Address)__','url'=>HTTP.'modules/address/address.php?id_company=@id@') ));
-
define the good template
@$conf->template->TCompany->card = ROOT.'modules/company/template/company.html';
-
And you SQL list
@$conf->list->TCompany->companyList=array( 'sql'=>"SELECT id, name, phone, email, web FROM ".DB_PREFIX."company WHERE id_entity IN (@getEntity@)" ,'param'=>array( 'title'=>array( 'name'=>'__tr(Name)__' ,'phone'=>'__tr(Phone)__' ,'email'=>'__tr(Email)__' ,'web'=>'__tr(Web)__' ) ,'hide'=>array('id') ,'link'=>array( 'name'=>'<a href="'.HTTP.'modules/company/company.php?action=view&id=@id@">@name@</a>' ) ,'search'=>array( 'name'=>true ,'phone'=>true ,'email'=>true ) ) );