Jump to content

Modules and multiple admin controllers


Appwards

Recommended Posts

Hi all,

 

The Question:

How can I have (and link to) other admin controllers for my module?

 

The situation

 

I'm using PS 1.6

 

My module has an "AdminMyModuleController".

I added a menu (tab) item in the BO and when I click it I see the expected output of my module.

 

That output links to other controllers from my module.

But that's where it goes wrong.

 

(Links are generated using "Context::..link->getAdminLink" function and look like: http://myshop/admin1234/index.php?controller=AdminMyModuleAccounts&token=7de69049a49431180becbbb69fcb8805)

 

I always get an error that the controller couldn't be found and reading the code it seems I can only access these controllers if they are also part of the menu (tab).

 

That can't be right, can it?

 

More background info:

 

Stacktrace

The route that leads to the AdminNotFoundController to be loaded instead of mine.

#0 AdminNotFoundControllerCore->initContent() called at [/var/www/html/prestashop/classes/controller/Controller.php:180] #1 ControllerCore->run() called at [/var/www/html/prestashop/classes/Dispatcher.php:374] #2 DispatcherCore->dispatch() called at [/var/www/html/prestashop/admin4664/index.php:54]

 

The controller class

The filename of the extra controller and name of class are also correct:

 

..../modules/mymodule/controllers/admin/AdminMyModuleAccountsController.php with class definition class AdminMyModuleAccountsController extends ModuleAdminController

 

..../modules/mymodule/controllers/admin/AdminMyModuleController.php with class definition class AdminBolcomController extends ModuleAdminController

 

 

Thanks in advance for your kind responses.

Link to comment
Share on other sites

Hi Vedia, thanks for your response.

 

I don't add the tab during installation.

I added it manually through the "Administration -> Menus" screen, unwittingly making my module's main controller work.

 

B.t.w.:I also tried Context::getContext()->link->getModuleLink('mymodule', 'AdminMyModuleAccounts') but that renders a URL that doesn't go to the admin section and just results in a 404. The link is: http://localhost:8081/index.php?fc=module&module=MyModule&controller=AdminMyModuleAccounts&id_lang=1

 

 

But, is it true that for module controllers to work there must be a tab linking to it?

Edited by mennobb (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...