samuelprabhu Posted May 28, 2015 Share Posted May 28, 2015 Hi! How to create new admin page in prestashop 1.6.x. I have followed the below steps in previous occasion: create controllers/admin/AdminPageController.php with the follwing content: class AdminPageController extends AdminController{public function initContent(){parent::initContent();$smarty = $this->context->smarty;$smarty->assign('test', 'test1');}} Delete: /cache/class_index.php Create: admin\themes\default\template\controllers\page\content.tpl zzz{$test}zzz At BackOffice -> Administration -> Menus -> [Add New]: Name: PageClass: AdminPageParent: Catalog Click the [save] button and the menu item should appear at the "Catalog" menu. The above steps worked well in prestashop 1.5.x versions. I tried the same in pretashop 1.6.x, but it is showing blank even after explicitly write the html content in tpl file or give the assigned smartry variable 'test'. My questions are, 1) how to call the custom tpl file in custom admin controller to show tpl content in prestashop 1.6.x? 2) how to send values to tpl file from custom admin controller in prestashop 1.6.x? 3) how to assign the tpl file to a php variable? I need to create custom controller and custom tpl in admin and need to show in admin. Anyone please help me to sort out this with sample code. Link to comment Share on other sites More sharing options...
CristianNC Posted May 28, 2015 Share Posted May 28, 2015 Hi samuelprabhu, I would like to know the same thing. I had 2 days in hell trying to figure this out. I`ve searched for the full documentation for ps and i didn`t find it ... is there one ? Link to comment Share on other sites More sharing options...
jgamio Posted May 28, 2015 Share Posted May 28, 2015 Look these module https://github.com/PrestaEdit/Canvas-Module-Prestashop-15 Have all you need to build your module back office 1 Link to comment Share on other sites More sharing options...
CristianNC Posted May 28, 2015 Share Posted May 28, 2015 Thx jgamio. I have another question regarding the module. Where are the tabs shown ? Because after i installed the module i was hopping that i will see in the left a menu with a sub element ... but they are not there ... I`m missing something ? Regards Link to comment Share on other sites More sharing options...
jgamio Posted May 29, 2015 Share Posted May 29, 2015 The sample put the menu on the main menu at bottom with aditional menu look the install function, i dont know why didnt work for you but look close 1) Jus create the tab object $parent_tab = new Tab(); 2) Just put the name in the actual language $parent_tab->name[$this->context->language->id] = $this->l('Main Tab Example'); 3) Set the class name Your controller $parent_tab->class_name = 'AdminMainExample'; 4) Set the parent code You can see defaults codes on your database look for ps_tabs, if you need create a generic these is not the best you should find the paren from database to create the parent $parent_tab->id_parent = 0; // Home tab 5) Set the module from the menu $parent_tab->module = $this->name; 6) Add the tab to the database $parent_tab->add(); 7) you have a position to set the position on the list 2 Link to comment Share on other sites More sharing options...
CristianNC Posted May 29, 2015 Share Posted May 29, 2015 The sample put the menu on the main menu at bottom with aditional menu look the install function, i dont know why didnt work for you but look close 1) Jus create the tab object $parent_tab = new Tab(); 2) Just put the name in the actual language $parent_tab->name[$this->context->language->id] = $this->l('Main Tab Example'); 3) Set the class name Your controller $parent_tab->class_name = 'AdminMainExample'; 4) Set the parent code You can see defaults codes on your database look for ps_tabs, if you need create a generic these is not the best you should find the paren from database to create the parent $parent_tab->id_parent = 0; // Home tab 5) Set the module from the menu $parent_tab->module = $this->name; 6) Add the tab to the database $parent_tab->add(); 7) you have a position to set the position on the list Hi jgamio, Thank you for helping me out. At second point i`ve used a loop to set the tab for all the languages installed : foreach (Language::getLanguages(true) as $lang) { $tab->name[$lang['id_lang']] = $this->l('Name displayed on the tab'); } at 3 ... for the main tab i`ve set the parent = 0 and for the child one i`ve set the parent tab id as in the module canvas Another thing that i don`t not understand is the $tab->class_name. In the canvas module for the parent it sets this property to AdminMainExample (and here i have a problem because i can not find this class in the canvas module package). The rest is clear for me, but when i install the module if i check the ps_tab table i can not find my new tabs in there :| and i receive no error message. Regards, Cristian Nicolae Nicorici Link to comment Share on other sites More sharing options...
CristianNC Posted May 29, 2015 Share Posted May 29, 2015 // 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 = 'AdminMainExample'; $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(); Sorry this is from the module canvas. I forgot to include it in the prev post. Regards, Cristian Nicolae Nicorici Link to comment Share on other sites More sharing options...
jgamio Posted May 29, 2015 Share Posted May 29, 2015 Hi I think they put on the parent a generic name class no a real one because these only is used to show the item Iink the menu I dont know why didnt install I use these for my own modules it works Are you sure is no data on ps_tabs Link to comment Share on other sites More sharing options...
samuelprabhu Posted June 1, 2015 Author Share Posted June 1, 2015 (edited) The sample put the menu on the main menu at bottom with aditional menu look the install function, i dont know why didnt work for you but look close 1) Jus create the tab object $parent_tab = new Tab(); 2) Just put the name in the actual language $parent_tab->name[$this->context->language->id] = $this->l('Main Tab Example'); 3) Set the class name Your controller $parent_tab->class_name = 'AdminMainExample'; 4) Set the parent code You can see defaults codes on your database look for ps_tabs, if you need create a generic these is not the best you should find the paren from database to create the parent $parent_tab->id_parent = 0; // Home tab 5) Set the module from the menu $parent_tab->module = $this->name; 6) Add the tab to the database $parent_tab->add(); 7) you have a position to set the position on the list Hi! Jgamio, Thanks for your answer. I have created the admin page as mentioned in the link you provided. I still have some doubts in that admin example controller, 1) I need to edit the query that displays the list ? 2) How to get and insert values from form created with helper class as in the example? Edited June 1, 2015 by samuelprabhu (see edit history) Link to comment Share on other sites More sharing options...
jgamio Posted June 1, 2015 Share Posted June 1, 2015 HI, You should look the code got to /controllers/admin check out how they work take a simple one like AdminStatesController you can see there how put some relations and how insert and edit new data Link to comment Share on other sites More sharing options...
samuelprabhu Posted June 3, 2015 Author Share Posted June 3, 2015 HI, You should look the code got to /controllers/admin check out how they work take a simple one like AdminStatesController you can see there how put some relations and how insert and edit new data Thanks a lot.. Job done... One question is there any way to find the difference between add and edit in postProcess() method. 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