jayashanka Posted November 21, 2023 Share Posted November 21, 2023 Hi All, I have tried to add a custom page using a custom module. But it gives a 404 error. I couldn't find any issue or error log. Appreciate if you could help on this. I have attached custom module file here for your kind reference. customservices.zip Link to comment Share on other sites More sharing options...
ps8modules Posted November 21, 2023 Share Posted November 21, 2023 (edited) Hi, https://validator.prestashop.com/auth/login Prestashop has a module checking tool. Is there a reason why you are duplicating the topic? Edited November 21, 2023 by ps8moduly.cz (see edit history) Link to comment Share on other sites More sharing options...
rthakur Posted November 21, 2023 Share Posted November 21, 2023 3 hours ago, jayashanka said: Hi All, I have tried to add a custom page using a custom module. But it gives a 404 error. I couldn't find any issue or error log. Appreciate if you could help on this. I have attached custom module file here for your kind reference. customservices.zip 2.02 kB · 0 downloads Follow below code create a new page following the next steps: Create the controller: /controllers/front/MyPageController.php <?php class MyPageControllerCore extends FrontController { public $php_self = 'mypage'; public $ssl = true; public function initContent() { parent::initContent(); $this->setTemplate('mypage'); } } Create the tpl file in your theme: /themes/YOUR_THEME/templates/mypage.tpl {extends file='page.tpl'} {block name='page_header_container'} {/block} {block name='page_content'} PAGE CONTENT HERE {/block} Delete the cache /var/cache/dev/ and /var/cache/prod/ How to access it: http://your-site.com/index.php?controller=mypage 1 1 Link to comment Share on other sites More sharing options...
ps8modules Posted November 21, 2023 Share Posted November 21, 2023 (edited) Updated your module: customservices.zip Edited November 21, 2023 by ps8moduly.cz (see edit history) 1 Link to comment Share on other sites More sharing options...
jayashanka Posted November 21, 2023 Author Share Posted November 21, 2023 6 hours ago, rthakur said: Follow below code create a new page following the next steps: Create the controller: /controllers/front/MyPageController.php <?php class MyPageControllerCore extends FrontController { public $php_self = 'mypage'; public $ssl = true; public function initContent() { parent::initContent(); $this->setTemplate('mypage'); } } Create the tpl file in your theme: /themes/YOUR_THEME/templates/mypage.tpl {extends file='page.tpl'} {block name='page_header_container'} {/block} {block name='page_content'} PAGE CONTENT HERE {/block} Delete the cache /var/cache/dev/ and /var/cache/prod/ How to access it: http://your-site.com/index.php?controller=mypage @rthakur thank you for sharing this code. It works. Only issue is using controller parameter in URL. if we can set routing and make URL short, this works well. I would like to know if this is possible. Link to comment Share on other sites More sharing options...
jayashanka Posted November 21, 2023 Author Share Posted November 21, 2023 2 hours ago, ps8moduly.cz said: Updated your module: customservices.zip 6.68 kB · 1 download @ps8moduly.cz thank you so much. you saved me once again. your code works well as expected. 1 Link to comment Share on other sites More sharing options...
ps8modules Posted November 21, 2023 Share Posted November 21, 2023 14 minutes ago, jayashanka said: @ps8moduly.cz thank you so much. you saved me once again. your code works well as expected. I'm glad I helped. You can rename the page in the seo & URL settings. 1 Link to comment Share on other sites More sharing options...
jayashanka Posted November 22, 2023 Author Share Posted November 22, 2023 11 hours ago, ps8moduly.cz said: I'm glad I helped. You can rename the page in the seo & URL settings. Thank you, I have added it to SEO & URLs. And then I tried to add this page to front office main menu from "Configure Main Menu" like below. And then like below, But About Us menu item is not appearing in Main Menu. Any reason for this? Link to comment Share on other sites More sharing options...
ps8modules Posted November 22, 2023 Share Posted November 22, 2023 Hi, Need to add a link below. Link to comment Share on other sites More sharing options...
Nitesh Kumar 35 Posted November 29, 2023 Share Posted November 29, 2023 How to resolve 404 Error. Link to comment Share on other sites More sharing options...
ps8modules Posted November 30, 2023 Share Posted November 30, 2023 Hi. Did you read the whole thread? Here is a working sample module. No 404 error is displayed. 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