aymeric69001 Posted August 17, 2023 Share Posted August 17, 2023 Hello, I am trying to display a link on the back office left menu in Prestashop (see the Modern Controllers part here ) Here is the hierarchy of my module's files: mysupermodule config routes.yml services.php services.yml dev ... NOT RELEVANT HERE src Controller DemoController.php vendor ... NOT RELEVANT here views js app.js chunk-vendor.js templates admin app.tpl mysupermodule.php routes.yml mysupermodule: path: mysupermodule/demo methods: [GET] defaults: _controller: 'MySuperModule\Controller\DemoController::demoAction' _legacy_controller: 'MySuperModuleDemoController' _legacy_link: 'MySuperModuleDemoController' services.yml services: _defaults: public: true your_company.mysupermodule.your_service: class: YourCompany\MySuperModule\DemoController arguments: - "@translator" - "My custom message" imports: - { resource: services.php } DemoController.php namespace MySuperModule\Controller; use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; use Symfony\Component\HttpFoundation\Response; use Context; use ModuleCore; class DemoController extends FrameworkBundleAdminController { public function demoAction() { $context = Context::getContext(); $module = ModuleCore::getInstanceByName("mysupermodule"); $context->smarty->assign([ 'pathApp' => $module->getPathUri() . 'views/js/app.js', 'chunkVendor' => $module->getPathUri() . 'views/js/chunk-vendors.js', ]); die($context->smarty->fetch('module:'.'mysupermodule'.'/views/templates/admin/app.tpl')); } } mysupermodule.php <?php if (!defined('_PS_VERSION_')) { exit; } class MySuperModule extends Module { public function __construct() { $this->name = 'mysupermodule'; $this->tab = 'front_office_features'; $this->version = '1.0.0'; $this->author = 'Aymeric 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('SUpermodule for your Prestashop'); $this->description = $this->l('This module allows you to ....'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); } public function install() { return parent::install() && $this->installTab(); // && $this->_installSql() && $this->_installTab(); } public function uninstall() { return parent::uninstall() && $this->uninstallTab(); // && $this->_uninstallSql() && $this->_uninstallTab(); } public function enable($force_all = false) { return parent::enable($force_all) && $this->installTab() ; } public function disable($force_all = false) { return parent::disable($force_all) && $this->uninstallTab() ; } private function installTab() { $tabId = (int) Tab::getIdFromClassName('MySuperModuleDemoController'); if (!$tabId) { $tabId = null; } $tab = new Tab($tabId); $tab->active = 1; $tab->class_name = 'MySuperModuleDemoController'; // Only since 1.7.7, you can define a route name $tab->route_name = 'admin_my_symfony_routing'; $tab->name = array(); foreach (Language::getLanguages() as $lang) { $tab->name[$lang['id_lang']] = $this->trans('My Module Demo', array(), 'Modules.MySuperModule.Admin', $lang['locale']); } $tab->id_parent = (int) Tab::getIdFromClassName('ShopParameters'); $tab->module = $this->name; return $tab->save(); } private function uninstallTab() { $tabId = (int) Tab::getIdFromClassName('MySuperModuleDemoController'); if (!$tabId) { return true; } $tab = new Tab($tabId); return $tab->delete(); } } So, a link should appear in the Shop Parameters section (see image below), but it does not .... Link to comment Share on other sites More sharing options...
ps8modules Posted August 18, 2023 Share Posted August 18, 2023 Hi. https://github.com/PrestaShop/example-modules/tree/master/democontrollertabs Link to comment Share on other sites More sharing options...
aymeric69001 Posted August 18, 2023 Author Share Posted August 18, 2023 thanks, solution : replace "mysupermodule" (first line of routes.yml) with admin_my_symfony_routing So now, it appears, BUT when I click on the link, it redirect to a full page with the content of my admin page (so that's great) but without all the admin surroundings (i.e. the left menu, the admin header etc.) 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