Skip to content

Instantly share code, notes, and snippets.

@eewee
Last active June 21, 2020 18:20
Show Gist options
  • Save eewee/fecf9e3065a5cb15db72d65be435ec39 to your computer and use it in GitHub Desktop.
Save eewee/fecf9e3065a5cb15db72d65be435ec39 to your computer and use it in GitHub Desktop.
// A METTRE DANS LE CONSTRUCTEUR D'UN MODULE
//------------------------------------------------------------
public function __construct()
// URL du front controller
//echo 'yoooooooooo : '.$this->context->link->getModuleLink('eewee_sellsy', 'fcont').'<hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr><hr>';
// http://www.webaki.com/blog/ajouter-menu-backoffice-module-prestashop-146.html
// Create menu custom
// $this->installTab('AdminEeweeParentTab', 'Eewee');
//
// $this->installTab('AdminEeweeModuleTab', 'Module Eewee Tab', 'AdminEeweeParentTab');
// $this->installTab('AdminSubChildTab1', 'Manage eewee Tab 1', 'AdminEeweeModuleTab');
// $this->installTab('AdminSubChildTab2', 'Manage eewee Tab 2', 'AdminEeweeModuleTab');
// Delete menu custom
// $tbl_delete = array(
// 'AdminEeweeParentTab',
// 'AdminEeweeModuleTab',
// 'AdminSubChildTab1',
// 'AdminSubChildTab2',
// );
// foreach ($tbl_delete as $d) {
// $tab = new Tab((int)Tab::getIdFromClassName($d));
// $tab->delete();
// }
// or
// $tab = new Tab();
// $tab->deleteSelection(array(142, 143, 144, 145, 146));
// check
// $xxx = Tab::getTabs(1);
// echo '<pre>'.var_export($xxx, true).'</pre>';
}// FIN CONSTRUCT
/**
* Create menu custom
* @param $className
* @param $tabName
* @param bool $tabParentName
* @return int
*/
public function installTab($className, $tabName, $tabParentName = false)
{
$tab = new Tab();
$tab->active = 1;
$tab->class_name = $className;
$tab->name = array();
foreach (Language::getLanguages(true) as $lang) {
$tab->name[$lang['id_lang']] = $tabName;
}
if ($tabParentName) {
$tab->id_parent = (int) Tab::getIdFromClassName($tabParentName);
} else {
$tab->id_parent = 0;
}
$tab->module = $this->name;
return $tab->add();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment