0
votes

I'm trying to create a new page template with Prestashop 1.7, and i understood i had to use a module for that.

i followed this tutorial : http://nemops.com/creating-new-pages-in-prestashop/#.WnrWa5OdVGy

Unfortunately, when i want to view the module i created using https://example.com/index.php?fc=module&module=aktest&controller=testindex i get a 404 page ...

Module (modules/aktest/aktest.php)

<?php
if (!defined('_PS_VERSION_'))
  exit;

class Aktest extends Module
{
  public function __construct()
  {
    $this->name = 'aktest';
    $this->tab = 'front_office_features';
    $this->version = '1.0.0';
    $this->author = 'Me and nobody else';
    $this->need_instance = 0;
    $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); 
    $this->bootstrap = true;

    parent::__construct();

    $this->displayName = $this->l('My Module Name');
    $this->description = $this->l('My Module Description.');

    $this->confirmUninstall = $this->l('Uninstall?');
  }
}

Controller (modules/aktest/controllers/front/testindex.php) - blank for now

<?php
class AktestTestindexModuleFrontController extends ModuleFrontController{
    public function init(){
        parent::init();
    }
    public function initContent() {
        parent::initContent();
    }
}
1

1 Answers

0
votes

This might just be the shop system telling you that there is nothing to show.

When trying your code on a PrestaShop 1.7.5 install (and having PS_DEV_MODE=1) i get an HTTP 500 error along with the following PHP error on console:

[Thu Jan 31 06:29:28.106955 2019] [:error] [pid 39] [client 127.0.0.1:41558] PHP Fatal error:  Uncaught  --> Smarty: 0():Missing '$template' parameter <-- \n  thrown in /var/www/html/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php on line 177
[31/Jan/2019:06:29:27 +0000] "GET /index.php?fc=module&module=aktest&controller=testindex HTTP/1.1" 500 403 "-" "Mozilla/5.0 Agent"

So if you changed your controller code

<?php
class AktestTestindexModuleFrontController extends ModuleFrontController{
    public function init(){
        parent::init();
    }

    public function initContent() {
        parent::initContent();
        $this->setTemplate('module:aktest/views/templates/front/testindex.tpl');
    }
}

and created a minimal template at modules/aktest/views/templates/front/testindex.tpl with

{extends file='page.tpl'}

{block name='page_content'}
    Well hello there
{/block}

then your controller should display something.

Always good in case something doesnt work, turn on debug mode in Admin Panel -> Configure -> Advanced Settings -> Performance -> Debug Mode and check the logs.