PrestaShop: How to create a custom page without CMS

This post has been moved to the following LinkedIn article as I am not maintaining this blog here anymore.

https://www.linkedin.com/pulse/prestashop-how-create-custom-page-without-cms-iftakhar-hasan/

58 thoughts on “PrestaShop: How to create a custom page without CMS

  1. Hello I followed your tutorial, but when I hit the page index.php?page=custom-page nothing appear it brings the first page of the shop. Any advice? I use prestashop 1.6.0.9

    Like

  2. no my page doesn’t appear, I am not sure if css code is necessary, because I didnt use any. I am just try to display a “hello” message. My goal is to make a custom form. but first I need to see the page. thank you

    Like

    • The CSS part is optional, you’ll only need it if you are trying to incorporate some page specific styling that is not included in the global CSS.
      I am not sure what causing you the trouble.

      Like

      • Great article. I used your code to create my custom prestashop pages and it works well but I’m struggling with a couple of things. My new page has . I think this might also be causing some scripts not to load. {HOOK_HEADER} does not get loaded on this page and I’m wondering if its all related to that body tag not being set properly. Any help would be appreciated.

        Like

  3. Hello again. I saw that you also wanted to build a custom form. Could you help me on how I make it too. I know that is diffrent question from your post but I could not find any other tutorial for a custom form.
    thank you.

    Like

    • There are lots of ways depending on the functionality of your form. Just work on the custom-page.tpl file, see my comments in the code, use HTML for form elements, CSS for styles and JavaScript for functionality.

      Like

  4. Good post.

    If I go directly to xyz.com/custom-page.php It shows the content but the javascript for the nav menu and other resources don’t get loaded.

    And if i go to xyz.com/index.php?page=custom-page It shows the index page, and looks like the code in “CustomPageController” is not executed.

    ¿Why is repeated the part of include the custom-page.tpl in the Controller and in the custom-page,php?

    -CustomPageController:
    $this->setTemplate(_PS_THEME_DIR_.’custom-page.tpl’);

    -custom-page.php:
    $smarty->display(_PS_THEME_DIR_.’custom-page.tpl’);

    Like

  5. Hi Iftakhar, I have a question maybe you could answer, I have been doing a lot of research but no luck. Y created a custom html landing page, for a campaign, that I will link to my product page. I can upload the file to the root folder, and no problem it loads. But because it loads with my domain, and I will have it in different languages, I’d like to be able to load it with the /fr or /it in the domain, for SEO purposes. What do you think I should do?
    (I reached this post because I was looking at the possibility to fully customize a cms page, but I have not found a way to do it).

    Like

    • Hey sebacrispo, sorry for the late reply, haven’t been around here for quite a while. I haven’t worked with multi-language options before. But from your description, I would recommend you to do it with JavaScript. Write your code and then put it inside the script tag (enclosed by {literal}{/literal} tags of course) that I showed in the 3rd step. Good Luck!

      Like

    • Dear Seba,
      Have you solved the problem of multilenguage, Let me know! I have the same issue
      Thanks and regards

      Like

  6. Great article. I used your code to create my custom prestashop pages and it works well but I’m struggling with a couple of things. My new page has . I think this might also be causing some scripts not to load. {HOOK_HEADER} does not get loaded on this page and I’m wondering if its all related to that body tag not being set properly. Any help would be appreciated.

    Like

  7. Looks like some of my comment was stripped out. The sentence that is cut off should say… The new page has class = page-not-found in the body tag.

    Like

  8. hi i want to add recharge facility to my prestashop website, how do i do it? i am total numb at coding php and other things, i have sample php pages of recharge api from recharge company who is giving me api for their recharge system. how do i do this ? can you guide me for the same.

    Like

  9. Hi I managed to create a new page and everything loads fine. But the problem with my html form is it has php POST in the input fields, which is also printed in the page. I understand that tpl will not allow using php code in it. Is there any other way i can accomplish this?
    For example next to my username it prints this php statement.

    Username :
    Can i not show it on the php page?

    Like

  10. Hello Iftakhar, Thank you for the wonderful post. I tried it the only problem that i am getting is that i am having the page title as “404 error” is there a way to fix the problem? thanx.

    Like

  11. Hi Guys,
    All works nicely

    I have only one issue, how change the TITLE of the page.
    Also because it’s a dynamic field.
    I had already added the “custom-page”, in the SEO and URLs

    Do you know how to fix it?
    PS: Cache cleared

    Like

    • Hey Andrea! Sorry for the late reply. I was busy with a lot of other stuffs. Is that the meta title you are referring to? If so, here is an easy way. Instead of loading the original header, make a new file with everything copied from the main header file, but replacing the title loading part with a manual title, and include it in the first php file I made. Let me know if it works. And of course, if you do figure out a more elegant approach, do share it with us. Good luck!

      Like

  12. Hi Iftakhar Hasan,

    Thanks for the great tuts..Everything is working fine except for 2 things:
    — The Title in the window tab still says 404 error even after clearing PS cache
    — The columns on the left is no longer showing (using default theme)

    Like

  13. Thanks for the great tutorial.

    I followed through using my own file names but the result was a totally blank page.
    So I went through again using the custom-page name without making changes to your code and ended up with the same result.

    My V1.6.0.10 site uses friendly URLs so to call the page I just use http://www.site.com/custom-page
    The page was linked in the Preferences->SEO & URLs

    Any suggestions?

    Like

  14. Adding this to the Controller Class helped me to get rid of the 404 Error. Also the left menu is now shown:

    public $php_self = ‘custom-page’;
    public $ssl = true;

    Liked by 1 person

    • Thanks, I have it working now. This is proving to be very useful. I also had a missing ‘>’ that caused an issue.

      Like

    • where should I add these lines? the page is working, only the title shows 404 error. Preferences->SEO & URLs does not fix the title name issue.
      ps tutorial is great! helped a lot.

      Like

  15. My custom page is working but every time I update the code I need to clear cache because the page will not show if I don’t clear. How can I fix that. Thanks!

    Like

  16. Hi Iftakhar hasan
    Thanks for your article 🙂
    Its worked for me.
    but its give error like page_name is not defined, and also in body tag id=”pagenotfound” ,so i missed page name
    please give me solution

    thanks in advance 🙂

    Like

  17. I absolutely love your website.. Very nice colors
    & theme. Did you make this amazing site yourself?
    Please reply back as I’m trying to create my own personal blog and want to learn where
    you got this from or just what the theme is called.
    Many thanks!

    Like

  18. Hi Iftakhar,
    Thanks for your article 🙂
    I did like the steps you explained
    but its gives 50 error , i added the page from BO -> seo and urls,
    still shows the same error.
    please give me solution

    Thanks in advance.

    Like

    • 1)
      if you receive 500error you must change your environment to developer mode:
      On your server, open the /config/defines.inc.php file.
      Find this line: define(‘PS_MODE_DEV‘, false);
      In this line, change “false” to “true”.
      Save your changes.
      2)
      for controller you must Remove class_index.php
      cache/class_index.php

      Liked by 1 person

      • Hi abdezakari! Thanks for your help. I’ve removed “class_index.php” from cache as you’ve suggested me, but the name of the page doesn’t appear. Any idea?

        Like

      • Hi tag Soup ,
        under SEO&URLs you have :
        page =Controllername Example(Users)
        Title page= Welcome
        URL= name example (user)
        you can call mysite.com/name and not mysite.com/index.php?controller=custompage

        Like

  19. I follow your tutorials i have made a custom-page
    double checked everthing is properly done according to your tutorial
    but is not working for me.
    can you please help….

    Like

  20. Is there any different if we apply these steps using Prestashop 1.7? If there is different, please make a tutorial! Because I can’t find it anywhere. Thank u!

    Like

  21. Hello,
    I have to browse to the file like this: domain.com/link.php how to browse to it like this: domain.com/link without the .php extension

    Like

Ask a question or leave a reply!