0

So I have a module (Menu) that I built following a tutorial and I want to treat it as an area. I then want to build other modules (I have Magento's Hello World module currently integrated for testing) but I haven't been able to find anywhere how I can append hello world to my menu url?

e.g. the url for hello world is: /admin/helloworld/hello/index/ what I would like is something like /admin/myMenuFrontName/helloworld/hello/index/

but I'm not sure where to even begin. Any help would be much appreciated.

0

The answer is actually really easy when I gave it more thought:

You have a menu module to control menu links. Then you have an area-based module, e.g. helloworld

Then inside that you have folders per sub-module controller. E.g. the file tree should be something like:

Company
|----Module
|--------Menu
|--------HelloWorld
|------------Controller
|----------------Adminhtml
|--------------------Area1
|------------------------Index.php
|--------------------Area2
|------------------------Index.php

along with all the other files. Then set up routing like:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="helloworld" frontName="helloworld">
            <module name="Company_HelloWorld" />
        </route>
    </router>
</config>

then after that you can have helloworld/area1/index and so on

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.