Hi i try to create an admin module to prestashop 1.6 but i find some problems.
I would create ( after module installation ) a new tab in main menù and after click on it i would to show a template (.tpl) where the admin user can do some thing on Db.
I have create a folder and insert it in modules folder, in this folder there are this files:
- Controller > admin > AdminGcbulkController.php
- gcbulk.tpl
- gcbulk.php
gcbulk.php:
<?php
if (!defined('_PS_VERSION_'))
exit;
require(dirname(__FILE__) . '/gcbulk_header.class.php');
class gcbulk extends Module {
private $page_name = '';
public function __construct() {
$this->name = 'gcbulk'; // il nome del modulo (lo stesso del file principale)
$this->tab = 'others'; // sezione in cui va inserito
$this->version = 0.1;
$this->author = 'Autore';
$this->need_instance = 0;
/*
* need_instance specifica se un istanza del modulo deve essere caricata
* quando viene visualizzata la lista dei moduli
(di norma può essere lasciato a 0)
*/
parent::__construct();
$this->displayName = $this->l('Bulk');
$this->description = $this->l('Modulo Bulk');
$this->context->controller->addCSS(($this->_path).'gcbulk.css', 'all');
//$this->context->controller->addJS(($this->_path).'js/gc_bulk_script.js');
}
public function install() {
// Install Tabs
$parent_tab = new Tab();
// Need a foreach for the language
$parent_tab->name[$this->context->language->id] = $this->l('Bulk tab');
$parent_tab->class_name = 'AdminGcbulk';
$parent_tab->id_parent = 0; // Home tab
$parent_tab->module = $this->name;
$parent_tab->add();
if (!parent::install()
|| !$this->registerHook('admingc')
);
}
public function uninstall() {
// Uninstall Tabs
$tab = new Tab((int)Tab::getIdFromClassName('AdminGcbulk'));
$tab->delete();
// Uninstall Module
if (!parent::uninstall())
return false;
return true;
}
public function hookadmingc(){
$this->smarty->assign(array(
'ciao' => 'hola'
));
return $this->display(__FILE__, 'gcbulk.tpl');
}
}
?>
Controller > admin > AdminGcbulkController.php
<?php
class AdminGcbulkController extends ModuleAdminController
{
}
gcbulk.tpl containe simple html.
The creation of tab work fine but i don't know how to show .tpl after clik on it. Actualy return a blank page on the right of admin contents ( on left there is the menù )
Thanks for any help !
the controller should implement renderList as following :
I recommend you to move your tpl in this folder : /gcbulk/views/templates/admin/gcbulk.tpl