Indiesservice Posted March 12, 2013 Share Posted March 12, 2013 hi, i am a new prestashop developer my question is how to create a my own tab in prestashop admin when creating a my own modules plese help me. Link to comment Share on other sites More sharing options...
vekia Posted March 12, 2013 Share Posted March 12, 2013 You can find an answer for your question in other thread: http://www.prestasho...e-modules-page/ Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted March 12, 2013 Share Posted March 12, 2013 Hi, the great article is here: http://blog.belvg.com/how-to-create-a-custom-product-tab-in-prestashop.html Regards Link to comment Share on other sites More sharing options...
vekia Posted March 12, 2013 Share Posted March 12, 2013 Hi, the great article is here: http://blog.belvg.co...prestashop.html Regards i think that this article isn't related to the topic Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted March 12, 2013 Share Posted March 12, 2013 oh, I am sorry, it is my mistake Your link is absolutely true Link to comment Share on other sites More sharing options...
vekia Posted March 12, 2013 Share Posted March 12, 2013 oh, I am sorry, it is my mistake Your link is absolutely true but it doesn't change the fact that your article is very useful and it is related to the subject, of course good job, as always Alexander Link to comment Share on other sites More sharing options...
Indiesservice Posted March 15, 2013 Author Share Posted March 15, 2013 (edited) thanks vekia, but i write the this code is install() method in mymodule.php if (!$id_tab) { $tab = new Tab(); $tab->class_name = 'my modules'; $tab->id_parent = 0; $tab->name = 'my modules'; $tab->add(); } but it not display the admin tab in back office please help me Edited March 15, 2013 by Indiesservice (see edit history) Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted March 15, 2013 Share Posted March 15, 2013 (edited) For 1.5 I use something like that: $new_tab = new Tab(); $new_tab->class_name = 'AdminWaitProducts'; $new_tab->id_parent = Tab::getCurrentParentId(); $new_tab->module = $this->name; $languages = Language::getLanguages(); foreach ($languages as $language) { $new_tab->name[$language['id_lang']] = 'Waiting list'; } $new_tab->add(); Edited March 15, 2013 by Alexander Simonchik (see edit history) 1 Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted March 15, 2013 Share Posted March 15, 2013 And for uninstall use it: $idTabs = array(); $idTabs[] = Tab::getIdFromClassName('AdminWaitProducts'); foreach ($idTabs as $idTab) { if ($idTab) { $tab = new Tab($idTab); $tab->delete(); } } Link to comment Share on other sites More sharing options...
Indiesservice Posted March 15, 2013 Author Share Posted March 15, 2013 (edited) Dear Alex, thanks for the help and reply. But i need little more help from you,I am uploading an image so your are able to know that what i actually want(in red rectangle part). i will appreciate if you help me with this..... Thanks Edited March 15, 2013 by Indiesservice (see edit history) Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted March 15, 2013 Share Posted March 15, 2013 Ok, try to change code for install function with this: //$new_tab->id_parent = Tab::getCurrentParentId(); $new_tab->id_parent = 0; http://clip2net.com/clip/m0/1363336385-clip-22kb.png Link to comment Share on other sites More sharing options...
Indiesservice Posted April 1, 2013 Author Share Posted April 1, 2013 (edited) thanks, Alexander your code create a new tab add in Administration >> Menus >>my tab but it is not display the this red part in back office help me, again i am using PS 1.5.3.1 Edited April 1, 2013 by Indiesservice (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted April 2, 2013 Share Posted April 2, 2013 so, it was little misunderstanding... if you want to create new tab in back office in menu, you should create tab in install() function of your module. here is piece of code: // Install Tabs $parent_tab = new Tab(); $parent_tab->name = 'Main Tab Example'; $parent_tab->class_name = 'AdminMainExample'; $parent_tab->id_parent = 0; // Home tab $parent_tab->module = $this->name; $parent_tab->add(); $tab = new Tab(); $tab->name = 'Tab Example'; $tab->class_name = 'AdminExample'; $tab->id_parent = $parent_tab->id; $tab->module = $this->name; $tab->add(); 1 Link to comment Share on other sites More sharing options...
Indiesservice Posted April 2, 2013 Author Share Posted April 2, 2013 thanks, vekia it is working but we write the unistall() function following code $id_tab = Tab::getIdFromClassName($this->ClassName); if ($id_tab) { $tab = new Tab($id_tab); $tab->delete(); } but not remove the tab in backoffice when the mymodules is uninstall.... Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted April 2, 2013 Share Posted April 2, 2013 (edited) Indiesservice, did you try write adminTab class name instead of $this->ClassName? I meen something like that: $idTabs = array(); $idTabs[] = Tab::getIdFromClassName('AdminMainExample'); $idTabs[] = Tab::getIdFromClassName('AdminExample'); foreach ($idTabs as $idTab) { if ($idTab) { $tab = new Tab($idTab); $tab->delete(); } } Regards Edited April 2, 2013 by Alexander Simonchik (see edit history) 1 Link to comment Share on other sites More sharing options...
vekia Posted April 2, 2013 Share Posted April 2, 2013 you should check alexander piece of code :-) Link to comment Share on other sites More sharing options...
Indiesservice Posted April 5, 2013 Author Share Posted April 5, 2013 (edited) thanks, it is working create modules with the tab. but problem is when i creating 1. - I create /controllers/admin/AdminMyExampleController.php of mymodules folder like so AdminMyexampleController extends AdminController{} but it will dispaly this type of error Class 'AdminMyExampleController' not found in mypath\classes\controller\Controller.php on line 128 please give me a solution of this problems Edited April 5, 2013 by Indiesservice (see edit history) Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted April 5, 2013 Share Posted April 5, 2013 If you follow the guide by vekia: $tab->module = $this->name; this code means that your AdminMyExampleController, must be located in the folder with your module. Link to comment Share on other sites More sharing options...
Indiesservice Posted April 6, 2013 Author Share Posted April 6, 2013 (edited) hi Alexander when i creating the mymodules/controllers/admin/AdminMyExample.php of this code AdminMyexampleController extends AdminController{ this->table = 'myexample'; $this->className = 'Example'; $this->fields_list = array( 'id_myexample' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 20 ), 'first_name' => array( 'title' => $this->l('First Name'), 'width' => 'auto' ),); } it display the this type of error [PrestaShopDatabaseException] Unknown column 'a. id_myexample ' in 'order clause' SELECT SQL_CALC_FOUND_ROWS a.* FROM `ps_myexample` a WHERE 1 ORDER BY a.id_myexample ASC LIMIT 0,50 at line 605 in file classes/db/Db.php how to solve this problem some guide me Edited April 6, 2013 by Indiesservice (see edit history) Link to comment Share on other sites More sharing options...
Krystian Podemski Posted April 7, 2013 Share Posted April 7, 2013 There is no "id_myexample" in "ps_myexample" table. It's very simple error message 1 Link to comment Share on other sites More sharing options...
Indiesservice Posted April 8, 2013 Author Share Posted April 8, 2013 (edited) thanks, Kriystian Sorry it's my misunderstanding... i am fetch the wrong column name my another question is when we add the public function renderList() { $this->addRowAction('delete'); return parent::renderList(); } it will be display the icon delete but when i click this icon then it will be display the error ,like as Class 'Example' not found in C:\wamp\www\prestashop\classes\controller\AdminController.php on line 1047 please help me Edited April 8, 2013 by Indiesservice (see edit history) Link to comment Share on other sites More sharing options...
Krystian Podemski Posted April 8, 2013 Share Posted April 8, 2013 You assign this tab to "AdminExample" class which must: * EXIST * extends right class to be able to use delete() method See other classes to have example Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted April 8, 2013 Share Posted April 8, 2013 Indiesservice, $this->className = 'Example'; Do you include Example class into your script? Link to comment Share on other sites More sharing options...
Indiesservice Posted April 8, 2013 Author Share Posted April 8, 2013 (edited) i write some code of myproblem 1. - I create /controllers/admin/AdminMyExampleController.php like so: class AdminMyExampleController extends AdminController { $this->table = 'myexample'; $this->className = 'MyExample'; $this->fields_list = array( 'id_myexample' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 20 ), 'name' => array( 'title' => $this->l('name'), 'align' => 'center', 'width' => 20 ),............... public function renderList() { // Adds an Edit button for each result $this->addRowAction('edit'); // Adds a Delete button for each result $this->addRowAction('delete'); return parent::renderList(); } } 2. I create /classes/MyExample.php like class MyExampleCore extends ObjectModel{} this is my code Edited April 8, 2013 by Indiesservice (see edit history) Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted April 8, 2013 Share Posted April 8, 2013 You need to require your MyExample class in your AdminMyExampleController.php file. (see autoload class) Also I reccomend you to change MyExampleCore class to MyExample. Regards. Link to comment Share on other sites More sharing options...
Indiesservice Posted April 8, 2013 Author Share Posted April 8, 2013 i am change you said MyExampleCore class to MyExample. but itd does not change same error is dispaly Link to comment Share on other sites More sharing options...
Krystian Podemski Posted April 8, 2013 Share Posted April 8, 2013 and you have required done too? 1 Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted April 9, 2013 Share Posted April 9, 2013 I agree with Krystian, we mean it function: http://www.php.net/manual/en/function.require-once.php Link to comment Share on other sites More sharing options...
Indiesservice Posted April 9, 2013 Author Share Posted April 9, 2013 (edited) hi i am registering a hook for mymodule.php file like as public function install() { if (!parent::install() || !$this->installDB() || !$this->registerHook('productLeftColumn')) return false; return true; } public function hookLeftColumnProduct($params) { return $this->display(__FILE__, 'view/template/hook/mymodule.tpl'); } but it will not display the product page tpl file what is i do wrong please give me advice.. thanks Edited April 9, 2013 by Indiesservice (see edit history) Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted April 9, 2013 Share Posted April 9, 2013 1) did you figure out with AdminMyExampleController? 2) productLeftColumn is not exists in standart Prestashop 3) you register hook "productLeftColumn" but try to using "hookLeftColumnProduct" Regards Link to comment Share on other sites More sharing options...
Indiesservice Posted April 9, 2013 Author Share Posted April 9, 2013 (edited) thanks for your help 1)we figure out with AdminMyExampleController i am change the register to hookLeftColumnProduct but results is same Edited April 9, 2013 by Indiesservice (see edit history) Link to comment Share on other sites More sharing options...
Alex Simonchik BelVG Posted April 9, 2013 Share Posted April 9, 2013 Try to use this: $this->registerHook('displayLeftColumnProduct') and this: public function hookDisplayLeftColumnProduct($params) { ... Link to comment Share on other sites More sharing options...
Indiesservice Posted April 10, 2013 Author Share Posted April 10, 2013 thanks. Alexander it working........ thanks Link to comment Share on other sites More sharing options...
Generaal Posted May 27, 2014 Share Posted May 27, 2014 Hello folks, I have the follow prob in BO, horiz menu, have add a tab Google site map, via the BO function, now I want remove this tab, but I can even go the menu tab, to undo this mistake. When I hit the tab menu, I get: Admincontroller not found... Best regards, Generaal 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