Mukesh Ravi Posted May 22, 2013 Share Posted May 22, 2013 Hi everyone, I want to create new tab in admin for my module. How to create a new tab. someone can help me.....!! Thanks Link to comment Share on other sites More sharing options...
NemoPS Posted May 22, 2013 Share Posted May 22, 2013 You must create a back office controller. In your module's folder this would be the structure controllers/admin/AdminModuleName.php This file class must be named like class AdminmodulenameController extends ModuleAdminController. You can choose to add it when installing the module, or youy can add it manually from the admin menu. You can find an extended explanation in the prestashop docs 2 Link to comment Share on other sites More sharing options...
Mukesh Ravi Posted May 22, 2013 Author Share Posted May 22, 2013 "Thanks for your response" I make the same inside my module folder. and add a new tab from admin. but no benefit. I think I am doing something wrong. So please explain in detail , i am not getting it right. Also I want to add tab(under home category i,e. root level) at the time of module installation. So please tell me what code to use for it. waiting for your response......... Link to comment Share on other sites More sharing options...
SmartDataSoft Posted May 22, 2013 Share Posted May 22, 2013 You must create a back office controller. In your module's folder this would be the structure controllers/admin/AdminModuleName.php This file class must be named like class AdminmodulenameController extends ModuleAdminController. You can choose to add it when installing the module, or youy can add it manually from the admin menu. You can find an extended explanation in the prestashop docs hello, nemo1 that is for prestashop admin tab add but how can any one add tab particular menu which comes with prestashop by default. Link to comment Share on other sites More sharing options...
NemoPS Posted May 22, 2013 Share Posted May 22, 2013 hello, nemo1 that is for prestashop admin tab add but how can any one add tab particular menu which comes with prestashop by default. Wha...? I don't get the point anyway it's too long to be explained in detail in a forum post, here is the doc http://doc.prestashop.com/display/PS14/Creating+a+PrestaShop+module#CreatingaPrestaShopmodule-Creatingthemodule'sback-officetab,anditsclass Link to comment Share on other sites More sharing options...
Mukesh Ravi Posted May 23, 2013 Author Share Posted May 23, 2013 HelIo Nemo1, The doc link you given does not work in PS 1.5, it is for PS 1.4. So please suggest me for Prestashop 1.5, I am working on PS1.5 Link to comment Share on other sites More sharing options...
SmartDataSoft Posted May 23, 2013 Share Posted May 23, 2013 HelIo Nemo1, The doc link you given does not work in PS 1.5, it is for PS 1.4. So please suggest me for Prestashop 1.5, I am working on PS1.5 you can try with this doc http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module#CreatingaPrestaShopmodule-Creatingthemodule and it is for 1.5 hope this help you . Link to comment Share on other sites More sharing options...
Mukesh Ravi Posted May 23, 2013 Author Share Posted May 23, 2013 I did not find there. I have checked it before. Any other reference? Link to comment Share on other sites More sharing options...
vekia Posted May 23, 2013 Share Posted May 23, 2013 you can try with this doc http://doc.prestasho...eatingthemodule and it is for 1.5 hope this help you . unfortunately there is no informations about tab. here is a thread about admin tabs: http://www.prestashop.com/forums/topic/157626-how-does-admin-tabs-mvc-work/ and here is an example of working admin tabs module: https://github.com/PrestaEdit/Canvas-Module-Prestashop-15/blob/master/example.php 2 Link to comment Share on other sites More sharing options...
Mukesh Ravi Posted May 23, 2013 Author Share Posted May 23, 2013 Hey That's working fine Thank you very much vekia Link to comment Share on other sites More sharing options...
vekia Posted May 23, 2013 Share Posted May 23, 2013 awesome i marked this thread as solved if you've got any question related to this case - feel free to continue discussion here regarsd 1 Link to comment Share on other sites More sharing options...
mayokun Posted November 14, 2013 Share Posted November 14, 2013 Hello All, I have gone through the vast posts on this forum regarding creation of backoffice admin tabs. I have been able to successfully create the tabs. I can load the list but view and edit are not working! I am not sure of what I am doing wrongly! Kindly help. Below is the relevant portion of my code: Object Model =========== class InterswitchData extends ObjectModel { public $customername; public $order_reference; public $txn_reference; public $ret_reference; public $pay_reference; public $order_amount; public $txn_fee; public $total_payable; public $status; public $response_code; public $response_description; public $card_number; /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'interswitch_data', 'primary' => 'id_interswitch_data', 'multilang' => true, 'fields' => array( 'customername' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'order_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'txn_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'ret_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'pay_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'order_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), 'txn_fee' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), 'total_payable' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), 'status' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'response_code' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'response_description' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'card_number' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), ), ); } Admin Controller ================ class AdminInterswitchController extends ModuleAdminController { public function __construct() { $this->table = 'interswitch_data'; $this->className = 'InterswitchData'; $this->lang = true; $this->deleted = false; $this->addRowAction('edit'); $this->addRowAction('view'); $this->fields_list = array( 'id_interswitch_data' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 25 ), 'order_reference' => array( 'title' => $this->l('Reference'), 'width' => 'auto', ), 'txn_reference' => array( 'title' => $this->l('Txn Reference'), 'width' => 'auto', ), 'customername' => array( 'title' => $this->l('Customer'), 'width' => 'auto', ), 'order_amount' => array( 'title' => $this->l('Order Total'), 'width' => 'auto', ), 'txn_fee' => array( 'title' => $this->l('Txn Fee'), 'width' => 'auto', ), 'total_payable' => array( 'title' => $this->l('Total Payable'), 'width' => 'auto', ), 'status' => array( 'title' => $this->l('Status'), 'width' => 'auto', ), 'response_code' => array( 'title' => $this->l('Resp Code'), 'width' => 'auto', ), 'response_description' => array( 'title' => $this->l('Resp Description'), 'width' => 'auto', ), ); parent::__construct(); } public function renderForm() { if (!($obj = $this->loadObject(true))) return; if (Tools::isSubmit('id_interswitch_data')) { $interswitch_data = new InterswitchData((int)Tools::getValue('id_interswitch_data')); $parent = $shop->id_interswitch_data; } $this->fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('Interswitch'), 'image' => '../img/admin/cog.gif' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Customer:'), 'name' => 'customername', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Order Reference:'), 'name' => 'order_reference', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Transaction Reference:'), 'name' => 'txn_reference', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Order Total:'), 'name' => 'order_amount', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Transaction Fee:'), 'name' => 'txn_fee', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Total Payable:'), 'name' => 'total_payable', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Response Code:'), 'name' => 'response_code', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Response Description:'), 'name' => 'response_description', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Retrieval Reference:'), 'name' => 'ret_reference', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Payment Reference:'), 'name' => 'pay_reference', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Card Number:'), 'name' => 'card_number', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Status:'), 'name' => 'status', 'size' => 40 ), ), 'submit' => array( 'title' => $this->l('Query'), 'class' => 'button' ) ); return parent::renderForm(); } } SQL Table ========= // Create Table in Database $sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'interswitch_data` ( `id_interswitch_data` int(10) NOT NULL AUTO_INCREMENT, `customername` varchar(50), `order_reference` varchar(50), `txn_reference` varchar(50), `ret_reference` varchar(50), `pay_reference` varchar(50), `order_amount` DECIMAL(17,2) DEFAULT 0.00, `txn_fee` DECIMAL(17,2) DEFAULT 0.00, `total_payable` DECIMAL(17,2) DEFAULT 0.00, `status` varchar(20), `response_code` varchar(10), `response_description` varchar(50), `card_number` varchar(4), PRIMARY KEY (`id_interswitch_data`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'; Link to comment Share on other sites More sharing options...
Kogkalidis Posted August 16, 2014 Share Posted August 16, 2014 Any tutorial about creating a bunch of tabs during the install of the module and deleting them as soon as the module is uninstalled for ps 1.6.x please? I tried your suggestions but no solution Link to comment Share on other sites More sharing options...
tarek.fellah Posted February 26, 2015 Share Posted February 26, 2015 Any tutorial about creating a bunch of tabs during the install of the module and deleting them as soon as the module is uninstalled for ps 1.6.x please? I tried your suggestions but no solution This code should help public function install() { // Install Tabs $parent_tab = new Tab(); // Need a foreach for the language $parent_tab->name[$this->context->language->id] = $this->l('Main Tab Example'); $parent_tab->class_name = 'AdminControllerParentClassName'; $parent_tab->id_parent = 0; // Home tab $parent_tab->module = $this->name; $parent_tab->add(); $tab = new Tab(); // Need a foreach for the language $tab->name[$this->context->language->id] = $this->l('Tab Example'); $tab->class_name = 'AdminExample'; $tab->id_parent = $parent_tab->id; $tab->module = $this->name; $tab->add(); return parent::install(); } public function uninstall() { $tab = new Tab((int)Tab::getIdFromClassName('AdminExample')); $tab->delete(); $tabMain = new Tab((int)Tab::getIdFromClassName('AdminControllerParentClassName')); $tabMain->delete(); // Uninstall Module if (!parent::uninstall()) return false; return true; } 1 Link to comment Share on other sites More sharing options...
Nuno42 Posted March 9, 2016 Share Posted March 9, 2016 I need to add a tab for a module that is already installed, any thoughts? Link to comment Share on other sites More sharing options...
NemoPS Posted March 11, 2016 Share Posted March 11, 2016 You can use the previous code in a custom function, and have that trigger when you submit a certain button in the module's back office, when it runs the postProcess method Link to comment Share on other sites More sharing options...
Nuno42 Posted March 20, 2016 Share Posted March 20, 2016 I found this code but it's not working, can you help me please? i want to create menu tabs that link to specific module pages, i created this controller and linkedit at backoffice, but it gives me the 500 error, Thank you <?php class AdmintabController extends AdminController { public function __construct() { $url = 'index.php?controller=AdminCmsContent&id_cms=4&updatecms'; $url .= '&token='.Tools::getAdminTokenLite('AdminModules'); Tools::redirectAdmin($url); } } 1 Link to comment Share on other sites More sharing options...
NemoPS Posted March 21, 2016 Share Posted March 21, 2016 Where did you add that?You are missing all of the required info for the construct anyway, like these $this->bootstrap = true; $this->table = 'order'; $this->className = 'Order'; $this->lang = false; $this->addRowAction('view'); $this->explicitSelect = true; $this->allow_export = true; $this->deleted = false; $this->context = Context::getContext(); But there is more, like the select to get items. If you are interested, I have a modules development course that covers that Link to comment Share on other sites More sharing options...
Nuno42 Posted March 21, 2016 Share Posted March 21, 2016 Hi Nemo, I created a Admintabcontroller file at admin/controllers, I just need to connect the buttons to the modules pages, like it happens at the quick acess menu, if you have a course for this i would be happy to do it! Link to comment Share on other sites More sharing options...
NemoPS Posted March 21, 2016 Share Posted March 21, 2016 Here nemops.com/prestashop-modules-course/Please notice it teaches you how to create back office pages with modules (automatically)You will still be able to do it manually of course, just skipping the module definition part and using the folder you used now Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now