Manik Posted October 21, 2013 Share Posted October 21, 2013 how to create a new page in prestashop admin panel? I tried using creating a new admin controller file and in that set the template path and i created a menu using admin panel and there i mentioned the controller class name for that menu. when i try to open that menu it always shows that controller not found. can anyone help me, how to create a new page in prestashop admin panel? am using PS 1.5 version. <?php class AdminPageController extends AdminController {public function __construct(){parent::__construct();}public function initContent(){parent::initContent();$this->setTemplate(_PS_THEME_DIR_.'mypage.tpl');}} Link to comment Share on other sites More sharing options...
NemoPS Posted October 21, 2013 Share Posted October 21, 2013 Have you added the tab to the top menu using the Administration/menus interface? Or are you reaching it by hardcoding the url? Link to comment Share on other sites More sharing options...
Manik Posted October 21, 2013 Author Share Posted October 21, 2013 I added using the admin interface and I mentioned the new controller class name which i created. Am I doing right way? If not please guide me. Link to comment Share on other sites More sharing options...
NemoPS Posted October 21, 2013 Share Posted October 21, 2013 I know it's a silly question. but where did you put the controller file? Link to comment Share on other sites More sharing options...
Manik Posted October 21, 2013 Author Share Posted October 21, 2013 In controllers/admin folder. Please suggest me any tutorial or just tell me the steps needed to do this, because really I don't know how to do this.I want to create a new page in admin panel and need to show some static information in that page.If you know the steps, explain here please.. Link to comment Share on other sites More sharing options...
NemoPS Posted October 21, 2013 Share Posted October 21, 2013 Another silly question: have you tried deleting cache/class_index.php? I'm clueless otherwise, the path and file are ok Link to comment Share on other sites More sharing options...
Manik Posted October 21, 2013 Author Share Posted October 21, 2013 Yes I tried that also, but not getting the output. Its always display controller not found error. Don't know where am making mistake. Link to comment Share on other sites More sharing options...
NemoPS Posted October 21, 2013 Share Posted October 21, 2013 Try filling in the construct data like: $this->table = 'psticket'; $this->className = 'psTicketClass'; $this->module = 'psticket'; $this->lang = false; Of course leave out the module part if you don't use one Link to comment Share on other sites More sharing options...
Manik Posted October 21, 2013 Author Share Posted October 21, 2013 I filled the construct data as you mentioned, but still its not working. can you explain the steps please, I will start from beginning again. Link to comment Share on other sites More sharing options...
NemoPS Posted October 21, 2013 Share Posted October 21, 2013 There is no other step (that I know) it should work this way Unless I'm overseeing something Try this $this->setTemplate(_PS_THEME_DIR_.'mypage.tpl'); return parent::initContent(); instead of parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'mypage.tpl'); Link to comment Share on other sites More sharing options...
Manik Posted October 21, 2013 Author Share Posted October 21, 2013 (edited) Still its not working @ Nemo. I am making mistake somewhere , I will see some more controllers files and try again.Really thanks for your reply .. Do we need any class file for making this ? right now am working with only one controller file. Edited October 21, 2013 by Milky John (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted October 21, 2013 Share Posted October 21, 2013 How does the url look like? Did you call the menu class AdminPage? Link to comment Share on other sites More sharing options...
Manik Posted October 21, 2013 Author Share Posted October 21, 2013 It looks like index.php?controller=AdminPage&token=222300032bc576d5c92d695b858b3664 . Its not showing anything now. Some where wrong is there in coding. Link to comment Share on other sites More sharing options...
NemoPS Posted October 21, 2013 Share Posted October 21, 2013 What's the file structure now? try echoing out something like 'hi there' before returning parent::initContent() Link to comment Share on other sites More sharing options...
Manik Posted October 21, 2013 Author Share Posted October 21, 2013 http://awesomescreenshot.com/0081ut4c68 please check the image in this link. This is the file structure now. <?php class AdminPageController extends AdminController { public function __construct() { $this->table = 'Page'; $this->className = 'Page'; $this->module = ''; $this->lang = false; parent::__construct(); } public function initContent() { print_r("hi, there??"); //$this->setTemplate(_PS_THEME_DIR_.'mypage.tpl'); //return parent::initContent(); } } Link to comment Share on other sites More sharing options...
NemoPS Posted October 21, 2013 Share Posted October 21, 2013 Well, it's working then, but now that I think about it, you should *probably* (as i never added a template file this way) put the tpl file in your admin/theme/controllername folder. Then, try something like the product controller $tpl = $this->createTemplate('specific_prices_shop_update.tpl'); $tpl->assign(array( 'option_list' => $res, 'key_id' => 'id_group', 'key_value' => 'name' ) ); $this->content = $tpl->fetch(); Link to comment Share on other sites More sharing options...
Manik Posted October 21, 2013 Author Share Posted October 21, 2013 Its not showing yet. I created a folder named "page" in admin/themes/default/controllers and put the file in folder like this page/mypage.tpl and page/helpers/view/view.tpl. but both methods are not showing. I tried like this.. public function initContent() { print_r("hi, there??"); $tpl = $this->createTemplate('mypage.tpl'); $this->content = $tpl->fetch(); //return parent::initContent(); } Link to comment Share on other sites More sharing options...
NemoPS Posted October 21, 2013 Share Posted October 21, 2013 try returning the parent initContent instead of leaving it commented out, or return $this->content directly Link to comment Share on other sites More sharing options...
Manik Posted October 21, 2013 Author Share Posted October 21, 2013 I tried that one also, Its not showing yet. It seems that fetching the template file only the problem, other wise my echo statements printed there. and I tried with one more function as same as in products controller, but that also not working. Link to comment Share on other sites More sharing options...
LockerAgencia Posted November 1, 2013 Share Posted November 1, 2013 did you get this work Milky John?? Link to comment Share on other sites More sharing options...
NemoPS Posted November 1, 2013 Share Posted November 1, 2013 What about $this->setTemplate(_PS_THEME_DIR_.'mypage.tpl'); Link to comment Share on other sites More sharing options...
Manik Posted November 5, 2013 Author Share Posted November 5, 2013 Hi Nemo... Thanks for your reply. I got the answer.. here it is. 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: Page Class: AdminPage Parent: Catalog Click the [save] button and the menu item should appear at the "Catalog" menu. Hope It may help someone. 3 1 Link to comment Share on other sites More sharing options...
Ganesh Hipparkar Posted December 5, 2013 Share Posted December 5, 2013 Hey Milky , Thank you very much ur steps solved my problem also. Thanks Ganesh Link to comment Share on other sites More sharing options...
JasonWang Posted January 21, 2014 Share Posted January 21, 2014 Hi Nemo... Thanks for your reply. I got the answer.. here it is. 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: Page Class: AdminPage Parent: Catalog Click the [save] button and the menu item should appear at the "Catalog" menu. Hope It may help someone. Thank you Milky! Link to comment Share on other sites More sharing options...
guismol Posted January 22, 2014 Share Posted January 22, 2014 (edited) Thanks for the help provided !! Edited January 27, 2014 by guismol (see edit history) Link to comment Share on other sites More sharing options...
Esnyper Posted September 27, 2014 Share Posted September 27, 2014 (edited) delete Edited September 27, 2014 by Esnyper (see edit history) Link to comment Share on other sites More sharing options...
abdess Posted February 14, 2017 Share Posted February 14, 2017 Thank you Manik/Milky Link to comment Share on other sites More sharing options...
Recommended Posts