Trabla: PrestaShop: add custom menu tab into administration panel
Solving:
Steps Overview:
1. Create AdminMySettingsController.php file ( MySettings replace with yours name )
and add fields description
2. Put file into /var/www/prestashop/controllers/admin/ folder on web-server
3. Execute INSERTs into tables ps_tab ( set class_name = AdminMySettings , Controller.php is added automaticaly) and ps_tab_lang
4. Clear PrestaShop cache to view new tab
Steps:
1. Create AdminMySettingsController.php file ( MySettings replace with yours name )
and add fields description
<?php
class AdminMySettingsController extends AdminControllerCore{
public function __construct(){
$this->bootstrap = true;
$this->className = 'Configuration';
$this->table = 'configuration';
$this->controller_name = "AdminMySettings";
$this->fields_options = array(
'general' => array(
'title' => $this->l('General'),
'icon' => 'icon-cogs',
'fields' => array(
//This is my custom setting
// - saved in table "ps_configuration" with "name" = 'MY_SETTING_1'
'MY_SETTING_1' => array(
'title' => $this->l('My Setting 1'),
'hint' => $this->l('This is my setting 1'),
'type' => 'text',
'size' => '10'
),
),
'submit' => array('title' => $this->l('Save'))
),
);
parent::__construct();
}
}
?>
2. Put file into /var/www/prestashop/controllers/admin/ folder on web-server ,
change /var/www/prestashop/ to your path
3. Execute INSERTs into tables ps_tab ( set class_name = AdminMySettings , suffix Controller.php is added automaticaly) and ps_tab_lang
INSERT INTO ps_tab(id_tab,id_parent, class_name,module,position,active,hide_host_mode)
VALUES (1000,0,'AdminMySettings','',100, 1, 0) ;
where
1000 - id_tab , make sure you don't use already existed id
0 - id_parent , 0 means highest level, if you set id of existed tab - will be added as sub-menu
INSERT INTO ps_tab_lang( id_tab, id_lang, name) VALUES (1000,3,'My Settings');
where
3 - id of English from table ps_lang
4. Clear PrestaShop cache to view new tab -
login into administration panel -> Advance parameters -> Performance
No comments:
Post a Comment