6

In my current project I have developed several modules to add different pieces of functionality. I'd like the admin of each module to be managed from a shared frontName, for example:

  • Company_ProductModule (/admin/company/product/index...)
  • Company_CategoryModule (/admin/company/category/index...)
  • Company_CustomerModule (/admin/company/customer/index...)

I have another module, Company_AdminModule, which has this adminhtml/routes.xml:

<router id="admin">
    <route id="company" frontName="company">
        <module name="Company_AdminModule">
    </route>
</router>

The admin module has an adminhtml/menu.xml as follows:

<menu>
    <add id="Company_Admin::main" title="Company Name" module="Company_Admin" />
</menu>

Each module has an adminhtml/menu.xml as follows:

<menu>
    <add id="Company_Product::index" title="Product Management" module="Company_Product" parent="Company_Admin::main" action="company/product/" />
</menu>

This works in so far as the menu items are all added, and the URLs all look correct. However visiting each link added by a module which isn't Company_AdminModule just redirects to the admin homepage, I guess because it's looking for the controller in the Company_AdminModule module.

Is there any way to split out the controllers under this frontName, so each can sit within the correct module's Controller/Adminhtml/ directory?

Ultimately this is desirable because each additional module should be able to add to the admin menu (which it can) but also add to the URL structure in a 'neat' way.

2
  • What does the router.xml file look like for your other extensions? Jun 15, 2016 at 10:26
  • I don't have one at the moment - with what I want, it didn't make sense to add one with the same id and frontName, is this assumption flawed?
    – James
    Jun 15, 2016 at 13:57

1 Answer 1

8

I've honestly never tried, but best I can make out looking at examples from core, you should just need to add:

<router id="admin">
    <route id="company">
        <module name="Company_OtherModule">
    </route>
</router>

To each of your other extensions in order to register the modules controllers for that route.

2
  • 1
    So simple, and works perfectly, thanks Peter!
    – James
    Jun 15, 2016 at 14:25
  • it works ! , didn't know we can do this . Thanks Jun 3, 2021 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.