Removing the components administrator menu

So, your shiny new frontend component is all written and works flawlessly without any kind of bugs whatsoever and now you would like to remove the component menu item in the administrator Components menu. Why you say ? Of course because your shiny new component is a frontend-only component and you do not want to implement a dummy backend interface just because it is cool.

So here is how you do it, if you need to know how to create an installer script for your component, please refer to the official Joomla! MVC Component tutorial.

class Com_HelloworldInstallerScript {
    function postflight($type, $parent){
        if ($type == 'install' || $type == 'update') {
            $db = JFactory::getDBO();
            $query = $db->getQuery(true);
            $query->delete('#__menu');
            $id = JComponentHelper::getComponent('com_helloworld')->id;
            $query->where('component_id = '.$id);
            $query->where('client_id = 1');
            $db->setQuery($query);
            $db->query();
        }   
    }   
}

Note that during uninstall of a component which has had its menu entry removing in this manner, there will be a warning/error in versions 1.7.0 and older. The component will still uninstall like it should so do not worry if you see this error.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">