Jump to content

Edit History

Andrz2556

Andrz2556

I had created the module "mymodule"  and it installed, tried to open the controller in the page "http://prestashop.pp:8082/admin47181ymgj5ac4e10t7g/index.php?controller=AdminObjectifController&token=a9a1a411b98c9dccf03de19b2bbae6a3#/dashboard"
and had this error. This is my code in the module:

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

class Mymodule extends Module
{
    public function __construct()
    {
        $this->name = 'mymodule';
        $this->tab = 'front_office_features';
        $this->version = '1.0.0';
        $this->author = 'Firstname Lastname';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = [
            'min' => '1.7.0.0',
            'max' => '8.99.99',
        ];
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('My module');
        $this->description = $this->l('Description of my module.');

        $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

        if (!Configuration::get('MYMODULE_NAME')) {
            $this->warning = $this->l('No name provided');
        }
    }
    public function install()
    {
        $class = 'AdminObjectif';
        $tab = new Tab();
        $tab->class_name = $class;
        $tab->module = $this->name;
        $tab->id_parent = (int) Tab::getIdFromClassName('AdminParentCustomer');
        $langs = Language::getLanguages(false);
        foreach ($langs as $l) {
            $tab->name[$l['id_lang']] = $this->l('Objectifs');
        }
        $tab->save();
        return parent::install() && $this->registerHook('displayHome') && $this->createTabLink();
    }
    public function uninstall()
    {
        return (
            parent::uninstall()
            && Configuration::deleteByName('MYMODULE_NAME')
        );
    }
    public function createTabLink(){
        $tab=new Tab;
        foreach (Language::getLanguages() as $lang)
        {$tab-> name[$lang['id_lang']]=$this->l('Origin');
        }
        $tab->class_name="AdminOrigin";
        $tab->module=$this->name;
        $tab->id_parent=0;
        $tab->add();
        return true;
    }
    protected function generateControllerURI()
    {
        $router = SymfonyContainer::getInstance()->get('router');

        return $router->generate('my_route_name');
    }
}

and this in the controller:

<?php

class AdminObjectifController extends ModuleAdminController
{
    public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'objectifs';
        $this->className = 'Objectif';

        parent::__construct();
    }

    public function initContent()
    {
        $tpl = $this->context->smarty->createTemplate($this->getTemplatePath() . 'origin.tpl', $this->context->smarty);


        $tpl->assign(array(
            'my_var' => "test"
        ));

        $this->content .= $tpl->fetch();
        parent::initContent();
    }
}

Maybe you help me with this problem.Greetings

Andrz2556

Andrz2556

I had created the module "mymodule"  and it installed, tried to open the controller in the page "http://prestashop.pp:8082/admin47181ymgj5ac4e10t7g/index.php?controller=AdminObjectifController&token=a9a1a411b98c9dccf03de19b2bbae6a3#/dashboard"
and had this error. This is my code in the module:

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

class Mymodule extends Module
{
    public function __construct()
    {
        $this->name = 'mymodule';
        $this->tab = 'front_office_features';
        $this->version = '1.0.0';
        $this->author = 'Firstname Lastname';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = [
            'min' => '1.7.0.0',
            'max' => '8.99.99',
        ];
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('My module');
        $this->description = $this->l('Description of my module.');

        $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

        if (!Configuration::get('MYMODULE_NAME')) {
            $this->warning = $this->l('No name provided');
        }
    }
    public function install()
    {
        $class = 'AdminObjectif';
        $tab = new Tab();
        $tab->class_name = $class;
        $tab->module = $this->name;
        $tab->id_parent = (int) Tab::getIdFromClassName('AdminParentCustomer');
        $langs = Language::getLanguages(false);
        foreach ($langs as $l) {
            $tab->name[$l['id_lang']] = $this->l('Objectifs');
        }
        $tab->save();
        return parent::install() && $this->registerHook('displayHome') && $this->createTabLink();
    }
    public function uninstall()
    {
        return (
            parent::uninstall()
            && Configuration::deleteByName('MYMODULE_NAME')
        );
    }
    public function createTabLink(){
        $tab=new Tab;
        foreach (Language::getLanguages() as $lang)
        {$tab-> name[$lang['id_lang']]=$this->l('Origin');
        }
        $tab->class_name="AdminOrigin";
        $tab->module=$this->name;
        $tab->id_parent=0;
        $tab->add();
        return true;
    }
    protected function generateControllerURI()
    {
        $router = SymfonyContainer::getInstance()->get('router');

        return $router->generate('my_route_name');
    }
}

and this in the controller:

<?php

class AdminObjectifController extends ModuleAdminController
{
    public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'objectifs';
        $this->className = 'Objectif';

        parent::__construct();
    }

    public function initContent()
    {
        $tpl = $this->context->smarty->createTemplate($this->getTemplatePath() . 'origin.tpl', $this->context->smarty);


        $tpl->assign(array(
            'my_var' => "test"
        ));

        $this->content .= $tpl->fetch();
        parent::initContent();
    }
}

Maybe you help me with this problem.Greetings

×
×
  • Create New...