Skip to content
Advertisement

Prestashop 1.7 module front controller 404

I am developing a Prestashop 1.7 module and I have a problem with the Front Controller Module. When I try to access the page I get a 404 error.

Here are the files : modules/cbd_calculator/cbd_calculator.php

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

class Cbd_Calculator extends Module
{
    public function __construct()
    {
        $this->name = 'cbd_calculator';
        $this->tab = 'front_office_features';
        $this->version = '1.0.0';
        $this->author = 'jojo';
        $this->need_instance = 0;
        $this->controllers = ['display'];
        $this->ps_versions_compliancy = [
            'min' => '1.6',
            'max' => '1.7.99',
        ];
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('title module');
        $this->description = $this->l('description module');

        $this->confirmUninstall = $this->l('Êtes-vous sûr de vouloir désinstaller ?');
    }

    public function install()
    {
        if (Shop::isFeatureActive()) {
            Shop::setContext(Shop::CONTEXT_ALL);
        }

        Logger::addLog($this->context->link->getModuleLink('cbd_calculator', 'display'));
        return parent::install() && $this->registerHook('displayHome') &&
            $this->registerHook('actionFrontControllerSetMedia');
    }
}

modules/cbd_calculator/controller/front/display.php :

<?php
class Cbd_CalculatorDisplayModuleFrontController extends ModuleFrontController
{
    public function initContent()
    {
        parent::initContent();

        $this->context->smarty->assign([
            'title' => 'kappa',
            'text' => 'test kappa'
        ]);
        $this->setTemplate('module:cbd_calculator/views/templates/front/display.tpl');
    }
}

modules/cbd_calculator/views/templates/front/display.tpl :

<div>
Kappa
</div>

I call the uri: http://localhost/modules/cbd_calculator/display or http://localhost/index.php?fc=module&module=cbd_calculator&controller=display

They give me a 404 error…

I am blocked with this problem, how can I fix that

Thank you guys

Advertisement

Answer

It seems wrong path:

modules/cbd_calculator/controller/front/display.php

You have to add [s] char: modules/cbd_calculator/controllers/front/display.php

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement