Jump to content

How to create full custom page 1.7


Recommended Posts

Hello, 
 
I use prestashop 1.7 wirh the classic theme.
 
I would like to create a full HTML custom page.
I will probably include file 'page.tpl' and put my content in 'page_content' block.
 
I dont' really know wich is the best way to perform this.
 
I found some tutorials and start by creating a new module  :
 
 
I have created about.php file in this path : modules/xav/controllers/front/about.php
 
class XavAboutModuleFrontController extends ModuleFrontController
{
 
    /**
    * Assign template vars related to page content
    * @see FrontController::initContent()
    */
    public function initContent()
    {
        parent::initContent();
 
        $this->setTemplate('module:xav/views/templates/front/about.tpl');
    }
}
 
and about.tpl in this path : modules/xav/views/templates/front/about.tpl
 
I tried to acces to http://localhost/prestashop/module/xav/about but i got a 404 error.
 
Can u help me to create a custom content and manage the route to display this one.
 
Thank you

Link to comment
Share on other sites

You can have a look at the following link for doing what you are trying to do:

 


 

But you should not create a separate controller through a custom module to perform this simple task. You can create a CMS page with any HTML content from the admin panel under the following menu:

 

Improve -> Design -> Pages

 

Hope this helps.
Link to comment
Share on other sites

Thnak for your answer, 

 

I have seen all stack overflow post, especially this one but it seems that doesn't really work as expected.
 

I know i can create content by admin panel, but i can  only choose my layout for all CMS page content. (not a unique one)

 

Any idea on a method to call a template file directly ?

 

I really would like to mange my file, to include some hooks, extra lib... but i don't know how to call it throught a route with prestashop...

Link to comment
Share on other sites

I found the solution.

 

I haven't create a file xav.php in the root folder of my module 'xav'
In this class i have this code :

 

<?php
 
if (!defined('_PS_VERSION_'))
exit;
 
class xav extends Module
{
/* @var boolean error */
protected $_errors = false;
 
public function __construct()
{
$this->name = 'xav';
$this->tab = 'front_office_features';
$this->version = '1.0';
$this->author = 'Xav13';
$this->need_instance = 0;
 
parent::__construct();
 
$this->displayName = $this->l('xav');
$this->description = $this->l('Custom page Xav');
$this->confirmUninstall = $this->l('Are you sure you want to delete this module?');
}
 
public function install()
{
if (!parent::install())
return false;
return true;
}
 
public function uninstall()
{
if (!parent::uninstall())
return false;
return true;
}
}
 
Hope this can help.
Link to comment
Share on other sites

  • 1 year later...

I have almost same problem

I created a controller and tpl file

when I goto: myshop/module/mymodule/mycontroller

I get : 500 server error

Any one can help please?

Do I have to register the controller during installation of the module?

Link to comment
Share on other sites

  • 9 months later...

For those having similar problem. The solution in this article was tested on PS 1.7 and 1.7.4 and still works. Translate this page from French and follow carefully. All you need to do is to create a new file for controller.php and then place new .tpl file in your theme's folder. At the end, you assign the URL in SEO tab in PS admin and you can call your new custom page in front-end from http://yoursiteaddress.com/index.php?controller=yourname

I don't take ANY credits for the solution, all the hats off to Victor (victor-rodenas.com) for the solution which I tested on PS 1.7.4.

#prestashop #custom #page #bespoke #tpl

 

 

Screenshot 2019-05-15 at 06.15.47.png

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...