Andrz2556 Posted July 25, 2023 Share Posted July 25, 2023 (edited) 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 Edited August 11, 2023 by Andrz2556 (see edit history) Link to comment Share on other sites More sharing options...
AddWeb Solution Posted July 31, 2023 Share Posted July 31, 2023 Hi, To access your custom controller, the URL should be in the following format: http://prestashop.pp:8082/admin47181ymgj5ac4e10t7g/index.php?controller=AdminObjectif&token=a9a1a411b98c9dccf03de19b2bbae6a3#/dashboard Use AdminObjectif (without "Controller") in the URL as the controller name. Thanks! 1 Link to comment Share on other sites More sharing options...
Andrz2556 Posted July 31, 2023 Author Share Posted July 31, 2023 Okay, thank you a lot everything works fine! Link to comment Share on other sites More sharing options...
AddWeb Solution Posted July 31, 2023 Share Posted July 31, 2023 3 minutes ago, Andrz2556 said: Okay, thank you a lot everything works fine! Great! Thanks for the update. Could you kindly add a cup to my post? Thanks again! 1 Link to comment Share on other sites More sharing options...
Andrz2556 Posted August 1, 2023 Author Share Posted August 1, 2023 Yeah, sure why not 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now