4

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.

  • What does the router.xml file look like for your other extensions? – Peter O'Callaghan Jun 15 '16 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 '16 at 13:57
3

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.

  • 1
    So simple, and works perfectly, thanks Peter! – James Jun 15 '16 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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