Skip to content

How to create a module

Alexis edited this page Mar 20, 2014 · 1 revision
  1. Create your module in directory "modules"

  2. make directories : boxe, class, config, image, js, lang, lib, template

  3. create a config/config.php file

  4. 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 */ );

  5. Add hook TAtomic::addHook($conf , array('Notify','TProduct','Home') // where ,array( 'function'=>'hook' // function to call ,'object'=>'TCompanion' // in object ,'parameters'=>array() ) );

  6. Add menus TTemplate::addMenu($conf, 'TCompany', 'Companies', HTTP.'modules/company/company.php', 'company', '', false, 1);

  7. 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@') ));

  8. define the good template @$conf->template->TCompany->card = ROOT.'modules/company/template/company.html';

  9. 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 ) ) );

Clone this wiki locally