0

I was creating a custom menu to the Admin panel on Magento 2.

The code of menu.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <add id="Formation_Jobs::job_head" title="Jobs" module="Formation_Jobs" sortOrder="100" parent="Magento_Backend::content" resource="Formation_Jobs::job_head" />
        <add id="Formation_Jobs::department" title="Departments" module="Formation_Jobs" sortOrder="10" parent="Formation_Jobs::job_head" action="jobs/department" resource="Formation_Jobs::job" />
        <add id="Formation_Jobs::job" title="Jobs" module="Formation_Jobs" sortOrder="20" parent="Formation_Jobs::job_head" action="jobs/job" resource="Formation_Jobs::job" />
    </menu>
</config>

The structure of my folders (Module work perfectly) :

enter image description here

But the problem is I can't see the custom menu on my Admin Panel enter image description here

Is there any solution?

PS: I use setup:upgrade and cache:flush && setup:di:compile and still not work

PS 2: I try to make an error on menu.xml ( don't close a tag ) and when I lunch setup:upgrade, I didn't get any error

  • does the user have the resource? – Philipp Sander Mar 27 '19 at 11:18
  • router id ????? – Rk Rathod Mar 27 '19 at 11:19
  • is the module enabled? – Philipp Sander Mar 27 '19 at 11:20
  • I've tested your code. I changed the module name Formation_Jobs to my own module Vendor_Module. After that it worked fine. Maybe you can test it in another custom module. Also, check your own module for spell mistakes. Maybe thats the reason it doesnt work. – MartinE Mar 27 '19 at 11:31
  • @PhilippSander yes sir, the module is enabled – sayou Mar 27 '19 at 13:16
2

I've created a test module with the same name as yours. So check for namespaces. This works good:

app/code/Formation/Jobs/ect/module.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Formation_Jobs" setup_version="1.0.0" />
</config>

app/code/Formation/Jobs/registration.php

<?php
/* file: app/code/Speak/StockImporter/registration.php  */
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Formation_Jobs',
    __DIR__
);

app/code/Formation/Jobs/etc/adminhtml/menu.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
    <menu>
        <add id="Formation_Jobs::job_head" title="Jobs" module="Formation_Jobs" sortOrder="100" parent="Magento_Backend::content" resource="Formation_Jobs::job_head" />
        <add id="Formation_Jobs::department" title="Departments" module="Formation_Jobs" sortOrder="10" parent="Formation_Jobs::job_head" action="jobs/department" resource="Formation_Jobs::job" />
        <add id="Formation_Jobs::job" title="Jobs" module="Formation_Jobs" sortOrder="20" parent="Formation_Jobs::job_head" action="jobs/job" resource="Formation_Jobs::job" />
    </menu>
</config>
| improve this answer | |
  • Thanks for your help sir, the XML is very sensible, and I copied it from a website and something was on it for that it doesn't work, I write it from scratch and it work – sayou Mar 29 '19 at 16:49

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.