endriudb Posted November 19, 2013 Share Posted November 19, 2013 (edited) Hi all! I'm trying to follow the official tutorial for creating a module in PS 1.5. In the one for PS 1.4 I had no problem, but now, in the 1.5 version, I cannot make a link to custom controller working.. My custom module is named "endriutest". This is a piece of code in my "endriutest.php" function hookDisplayLeftColumn($params) { $this->hookDisplayHeader(); $this->context->smarty->assign(array( 'endriu_test_link' => $this->context->link->getModuleLink('endriutest', 'display') )); return $this->display(__FILE__, 'endriutest.tpl'); } and in the "endriutest.tpl" <a href="{$endriu_test_link}">Vai a una pagina custom</a> but when I click on the link, which comes out like "http://mydomain.it/module/endriutest/display", Prestashop can't find the page and give me an error.. I have "display.php" in my module's root and it should show a simple text like this Welcome to this page! I can't find the problem because I think I'm doin' the right things like the tutorial explains but something goes wrong somewhere.. Any ideas? Thank you Edited November 22, 2013 by endriudb (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted November 19, 2013 Share Posted November 19, 2013 hello have you got controller for this page? check this guide: http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module especially part: embedding template in the theme Link to comment Share on other sites More sharing options...
endriudb Posted November 20, 2013 Author Share Posted November 20, 2013 I'm following that guide, but when I tried to create the controller it didn't work (same error, page not found), so I turned back to the lines that say: Embedding a template in the theme The link that the module displays does not lead anywhere for now. Let's create the display.php file that it targets, with a minimal content, and put it in the module's root folder. display.php Welcome to this page! Click the "Click me!" link: the resulting page is just that raw text, without anything from the theme. We would like to have this text embedded in the theme, so let's see how to do just that. and tried to insert in the "display.php" only that line of raw html, but it doesn't appear anyway.. page not found... Link to comment Share on other sites More sharing options...
vekia Posted November 20, 2013 Share Posted November 20, 2013 can you show code of your controller and also link that you use to open this controller page? Link to comment Share on other sites More sharing options...
endriudb Posted November 20, 2013 Author Share Posted November 20, 2013 Well, it's all written in my first post...1) the first piece of code shows a part of my main module's class, where I set the hook for left column and, after assigning a smarty variable with the result of a call to "getModuleLink", I show the content of the main template2) the second piece of code shows a part of my main template, where I use the variable assigned before to set the "href" attribute of a link3) the third and last part is the content of my "display.php", which now doesn't contain a controller (I tried this before with same results) but just raw text;Now, following the guide, the raw text should appear on a new page when I click on the link builded before, but no, it reports a "page not found" error..So I wonder if I'm building the link correctly, but it seems I'm doin' just what the guide says, and the link itself seems to be correct, because it appears like <http://mydomain.it/module/endriutest/display"> where, obviously, "mydomain" is just to hide my real test domain I'm workin' on.. Hi all! I'm trying to follow the official tutorial for creating a module in PS 1.5. In the one for PS 1.4 I had no problem, but now, in the 1.5 version, I cannot make a link to custom controller working.. My custom module is named "endriutest". This is a piece of code in my "endriutest.php" function hookDisplayLeftColumn($params) { $this->hookDisplayHeader(); $this->context->smarty->assign(array( 'endriu_test_link' => $this->context->link->getModuleLink('endriutest', 'display') )); return $this->display(__FILE__, 'endriutest.tpl'); } and in the "endriutest.tpl" <a href="{$endriu_test_link}">Vai a una pagina custom</a> but when I click on the link, which comes out like "http://mydomain.it/module/endriutest/display", Prestashop can't find the page and give me an error.. I have "display.php" in my module's root and it should show a simple text like this Welcome to this page! I can't find the problem because I think I'm doin' the right things like the tutorial explains but something goes wrong somewhere.. Any ideas? Thank you Link to comment Share on other sites More sharing options...
vekia Posted November 20, 2013 Share Posted November 20, 2013 but you said that you followed guide (created controller) and i don't see it there. Link to comment Share on other sites More sharing options...
endriudb Posted November 20, 2013 Author Share Posted November 20, 2013 Yes, I said I followed guide and the guide, before creating the PHP logic of the controller, shows inserting raw text in "display.php" to make a simple text come out. But it doesn't happen on my side. This is the real problem as seems like the "display.php" script has not been called at all. Anyway, if you want to see what I inserted in the "display.php" to make it a "real" controller, here is the code: class endriutestdisplayModuleFrontController extends ModuleFrontController { public function initContent() { parent::initContent(); $this->setTemplate('display.tpl'); } } and the result is the same, page not found. but you said that you followed guide (created controller) and i don't see it there. Link to comment Share on other sites More sharing options...
endriudb Posted November 20, 2013 Author Share Posted November 20, 2013 Ok, solved. There is an error in the official guide, where it says Let's create the display.php file that it targets, with a minimal content, and put it in the module's root folder. If you put display.php in the module's root folder, you will have "page not found" error like me. After some rows, the guide says: Let's explore display.php, our first PrestaShop front-end controller, stored in the /controllers/front folder of the module's main folder: If you put display.php in /controllers/front, this will work! Maybe that is a section of the old version (1.4) of the guide that nobody has removed. Furthermore, it's not specified where I should put the template file, but trying, I found that it has to be put in /views/templates/front It would be good to modify the guide to teach the right steps Thanks anyway for help! 3 Link to comment Share on other sites More sharing options...
ax8400 Posted January 16, 2014 Share Posted January 16, 2014 (edited) Ok, solved. There is an error in the official guide, where it says Let's create the display.php file that it targets, with a minimal content, and put it in the module's root folder. If you put display.php in the module's root folder, you will have "page not found" error like me. After some rows, the guide says: Let's explore display.php, our first PrestaShop front-end controller, stored in the /controllers/front folder of the module's main folder: If you put display.php in /controllers/front, this will work! Maybe that is a section of the old version (1.4) of the guide that nobody has removed. Furthermore, it's not specified where I should put the template file, but trying, I found that it has to be put in /views/templates/front It would be good to modify the guide to teach the right steps Thanks anyway for help! I had the same problem, follow endriudb instructions to get the tutorial example module working.!! shame that I found it too late. But its a must do, for newbies&everywone , if you dont write display.tpl into: mymodule/views/templates/front the template will not show. Edited January 16, 2014 by ax8400 (see edit history) Link to comment Share on other sites More sharing options...
ax8400 Posted January 17, 2014 Share Posted January 17, 2014 (edited) I had the same problem, follow endriudb instructions to get the tutorial example module working.!! shame that I found it too late. But its a must do, for newbies&everywone , if you dont write display.tpl into: mymodule/views/templates/front the template will not show. If you want to test mymodule, same as official guide, but no need to re-write it, here is a link to download it: http://b.96.lt/Ny Edited January 17, 2014 by ax8400 (see edit history) Link to comment Share on other sites More sharing options...
benbensk Posted January 22, 2014 Share Posted January 22, 2014 (edited) See this: I follow the tutorial ( http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module#CreatingaPrestaShopmodule-Technicalprinciplesbehindamodule ) too and: I make this: public function hookDisplayLeftColumn($params) { $this->context->smarty->assign( array( 'my_module_name' => Configuration::get('MYMODULE_NAME'), 'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display') ..................... and the real link is: http://www.test.benben.sk/module/batfindmodule/display which does't work , so I tried this: 'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display.php') and the real link change on this: http://www.test.benben.sk/module/batfindmodule/display.php which is better but still does not work, so I manually change link on this: http://www.test.benben.sk/modules/batfindmodule/display.php it is working, so the problem is in the function - getModuleLink or what? The functions get wrong folder name of the module. it returns mainfolder/module/mymodule/display, but it should be mainfolder/modules/mymodule/display.php How I can change a getModuleLink function to work properly ? Thanx so I change the function and it's working: public function hookDisplayLeftColumn($params){ $this->context->smarty->assign( array( 'my_module_name' => Configuration::get('MYMODULE_NAME'), 'my_module_link' => $this->_path.('display.php') //'my_module_link' => $this->context->link->getModuleLink('batfindmodule', 'display.php') ) But to follow the tutorial it is not ok, it is still do not work. Any help ? Thanx Edited January 22, 2014 by benbensk (see edit history) Link to comment Share on other sites More sharing options...
benbensk Posted January 22, 2014 Share Posted January 22, 2014 See this: I follow the tutorial ( http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module#CreatingaPrestaShopmodule-Technicalprinciplesbehindamodule ) too and: I make this: public function hookDisplayLeftColumn($params) { $this->context->smarty->assign( array( 'my_module_name' => Configuration::get('MYMODULE_NAME'), 'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display') ..................... and the real link is: http://www.test.benben.sk/module/batfindmodule/display which does't work , so I tried this: 'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display.php') and the real link change on this: http://www.test.benben.sk/module/batfindmodule/display.php which is better but still does not work, so I manually change link on this: http://www.test.benben.sk/modules/batfindmodule/display.php it is working, so the problem is in the function - getModuleLink or what? The functions get wrong folder name of the module. it returns mainfolder/module/mymodule/display, but it should be mainfolder/modules/mymodule/display.php How I can change a getModuleLink function to work properly ? Thanx so I change the function and it's working: public function hookDisplayLeftColumn($params){ $this->context->smarty->assign( array( 'my_module_name' => Configuration::get('MYMODULE_NAME'), 'my_module_link' => $this->_path.('display.php') //'my_module_link' => $this->context->link->getModuleLink('batfindmodule', 'display.php') ) Link to comment Share on other sites More sharing options...
vekia Posted January 22, 2014 Share Posted January 22, 2014 http://www.test.benben.sk/module/batfindmodule/display - it's a controller, you have to create display controller. it's totally not related to module hooks as you suggested 1 Link to comment Share on other sites More sharing options...
rsaiz Posted June 4, 2014 Share Posted June 4, 2014 Ok, solved. There is an error in the official guide, where it says Let's create the display.php file that it targets, with a minimal content, and put it in the module's root folder. If you put display.php in the module's root folder, you will have "page not found" error like me. After some rows, the guide says: Let's explore display.php, our first PrestaShop front-end controller, stored in the /controllers/front folder of the module's main folder: If you put display.php in /controllers/front, this will work! Maybe that is a section of the old version (1.4) of the guide that nobody has removed. Furthermore, it's not specified where I should put the template file, but trying, I found that it has to be put in /views/templates/front It would be good to modify the guide to teach the right steps Thanks anyway for help! Wow, thank you, it was killing me! Link to comment Share on other sites More sharing options...
Fuel4mind Posted August 12, 2014 Share Posted August 12, 2014 Ok, solved. There is an error in the official guide, where it says Let's create the display.php file that it targets, with a minimal content, and put it in the module's root folder. If you put display.php in the module's root folder, you will have "page not found" error like me. After some rows, the guide says: Let's explore display.php, our first PrestaShop front-end controller, stored in the /controllers/front folder of the module's main folder: If you put display.php in /controllers/front, this will work! Maybe that is a section of the old version (1.4) of the guide that nobody has removed. Furthermore, it's not specified where I should put the template file, but trying, I found that it has to be put in /views/templates/front It would be good to modify the guide to teach the right steps Thanks anyway for help! Thanks allot you saved me 1 Link to comment Share on other sites More sharing options...
BurakD Posted February 11, 2015 Share Posted February 11, 2015 Thank you! Link to comment Share on other sites More sharing options...
Jibu Posted May 1, 2018 Share Posted May 1, 2018 Thank you! 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