I'am working with the last git changes of Joomla 4.0. In my component, i create the menu items during postflight step when installing a component. The issue is that isn't able to find at this step the component ID.

In thh script.php file of the component in the postflight (https://github.com/Kunena/Kunena-Forum/blob/K6.0/src/script.php#L265), i call a method to create the menu items :

$installer = new KunenaModelInstall;

The createMenu() method is located here : https://github.com/Kunena/Kunena-Forum/blob/K6.0/src/libraries/kunena/src/Install/KunenaModelInstall.php#L3022

menu manager of Joomla!

Why the component id isn't set at this step ? If i call the methode createMenu() after that teh component is installed i don't encounter this issue


The component id may not be available yet; you might be able to retrieve it from the db, I did find my own extension in the extensions table at this step but haven't tried; that seems overkill anyways.

Just add the menu and submenu items in the xml of the component, in the administration section, at the same level as files and folders something like this:

    <menu img="components/com_littlehelper/assets/images/logo16.png">COM_LITTLEHELPER</menu>
        <menu link="option=com_littlehelper&amp;view=trash_n_cache" img="components/com_littlehelper/assets/images/joomla16.png">COM_LITTLEHELPER_TRASH_AND_CACHE</menu>

and so on. You can create menus, submenus, and the translations will be automatically be applied. Joomla takes care of it all, so you can avoid the postflight altogether.

  • The menus which i want to create in postflight is for frontend. There is a menutype and some sub-menus which this menutype – user3533235 Jan 5 at 12:24

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.