Within a plugin I need to add and populate (data is available inside my plugin) a column to com_menus&view=menus view in administration.

enter image description here


public function onAfterInitialise()
    $input = JFactory::getApplication()->input;
    if (JFactory::getApplication()->isAdmin()
        && $input->getCmd('option') == 'com_menus'
        && $input->getCmd('view') == 'menus')
        JRequest::setVar('view', 'menusextra');
        JLoader::register('MenusViewMenusextra', __DIR__ . '/views/menus/view.html.php');


JLoader::register('MenusViewMenus', JPATH_ADMINISTRATOR . '/components/com_menus/views/menus/view.html.php');
JLoader::register('MenusModelMenus', JPATH_ADMINISTRATOR . '/components/com_menus/models/menus.php');

class MenusViewMenusextra extends MenusViewMenus
    public function display($tpl = null)
        $this->items         = $this->get('Items');
        $this->pagination    = $this->get('Pagination');
        $this->state         = $this->get('State');
        $this->filterForm    = $this->get('FilterForm');
        $this->activeFilters = $this->get('ActiveFilters');
        $this->canDo         = JHelperContent::getActions('com_menus');
        $this->db            = JFactory::getDbo();

        $this->addTemplatePath(__DIR__ . '/tmpl/');

class MenusModelMenusextra extends MenusModelMenus {}

Now, I am getting the error "JForm::getInstance could not load file". Think this is due because it is not being able to load the filter_menusextra.xml, the original (core) filter_menus.xml that is located \administrator\components\com_menus\models\forms. Is it because it uses the JLayout search tools and need to load the xml file?

Made the following test: renamed filter_menus.xml to filter_menusextra.xml in \administrator\components\com_menus\models\forms and it worked. But as I am overriding it I should be able to make it inside my plugin, not the core one?! What am I doing wrong?

Could someone help me please on this? Thank you.


Short answer

You can't. You can only try to process system output (via application output buffer or Java Script) or changing system files.

Long answer

Menu component would have to support custom plugin events but it does not. Modifying system files is a really bad idea and I advice you to avoid it. You can try to create a system plugin that will modify application output buffer but it would be vulnerable for code changes. More bulletproof would be to do it with JavaScript/jQuery. That way small changes in code will not affect your plugin functionality. Of course it has its downsides. You can't make this column sortable and you can't search its contents.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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