Missing Contacts categories from Component after Joomla 4 migration


If you upgraded your Joomla 3 site to Joomla 4, and everything is working, congratulations! If not, try to read some of the processes in my previous article. However, even after a successful upgrade, you can observe some errors in your Joomla Back End. One of the common ones I saw was missing "categories" from the "Contacts" menu within the Component section of the Joomla administration Back End. You can observe just one menu item missing or more, and not only by "Contacts" but as well by other menu items. The cause of this is an exception during the SQL queries run during the upgrade that is preventing to add, moving, etc... the items within the database table.

Remember, you can access the missing areas using a direct URL to verify the component is there, just not showing within the menu items. You can use the URL below to access the Contacts/Contacts menu item. If you will be redirected to a missing page, a 404 error, the problem is more serious but if you will be redirected to the appropriate page, there is just some mismatch within the database. This is something we can fix but remember, the root cause can be different from site to site and database to database. One method can work there and the second one somewhere else. Anyway, make a backup, and let's go to phpMyAdmin.

#Direct access to Contacts/Contacts

Open up your phpMyAdmin and choose your Joomla 4 database. In the filter add "menu" and then click on the table [preffix]_menu. Within this table change the "number of rows" to 500 and add to the filter "contact". this will filter out all entries with "contact" in the name. In a healthy database, you should have 5 entries.

1. com_contact
2. com_contact_contacts
3. com_contact_categories
4. mod_menu_fields
5. mod_menu_fields_group

The com_contact entry is the main component, and the rest are the sub-menus of it. As you can see I am missing all, and thus I have only the first item and thus com_contact. The other menu items are however accessible through a URL from the admin Back End and thus they are there just they do not have an entry in the database.

You can end up with all entries in your database but for example, with a wrong parent ID, etc... the solution is then more simple since you will just add the parent_id according to com_contact. We will however use some SQL queries to add the missing items to the database.

INSERT INTO `arfa_menu` (`id`, `menutype`, `title`, `alias`, `note`, `path`, `link`, `type`, `published`, `parent_id`, `level`, `component_id`, `checked_out`, `checked_out_time`, `browserNav`, `access`, `img`, `template_style_id`, `params`, `lft`, `rgt`, `home`, `language`, `client_id`, `publish_up`, `publish_down`) VALUES
(200, 'main', 'com_contact_contacts', 'Contacts', '', 'Contacts/Contacts', 'index.php?option=com_contact&view=contacts', 'component', 1, 107, 2, 8, NULL, NULL, 0, 0, 'class:contact', 0, '', 122, 123, 0, '*', 1, NULL, NULL),
(201, 'main', 'com_contact_categories', 'Categories', '', 'Contacts/Categories', 'index.php?option=com_categories&view=categories&extension=com_contact', 'component', 1, 107, 2, 6, NULL, NULL, 0, 0, 'class:contact-cat', 0, '', 124, 125, 0, '*', 1, NULL, NULL),
(202, 'main', 'mod_menu_fields', 'contact-custom-fields', '', 'Contacts/contact-custom-fields', 'index.php?option=com_fields&context=com_contact.contact', 'component', 1, 107, 2, 33, NULL, NULL, 0, 0, 'class:messages-add', 0, '{}', 128, 129, 0, '*', 1, NULL, NULL),
(203, 'main', 'mod_menu_fields_group', 'contact-custom-fields-group', '', 'Contacts/contact-custom-fields-group', 'index.php?option=com_fields&view=groups&context=com_contact.contact', 'component', 1, 107, 2, 33, NULL, NULL, 0, 0, 'class:messages-add', 0, '{}', 130, 131, 0, '*', 1, NULL, NULL);

The query is simple, we will ad in our case 4 rows into the table for: com_contact_contacts, com_contact_categories, mod_menu_fields, and mod_menu_fields_group. The first column [id] needs to be changed to a free row, and thus you need to edit this according to your table. The [parent_id] column is the [id] of the main component, com_contact, in my case it is 107. The [component_id] corresponds to the [table]_extension [id]. Look in the table for [id] for com_contact_contacts = com_contact, com_contact_categories = com_categories, mod_menu_fields, mod_menu_fields_group = com_fields. The last thing to tune up is the column [lft] and [rgt]. These need to be according to the main com_contact, all items should be inside the com_contact [lft] and [rgt].

And you are done. I hope it will help you to fix something about the Joomla 4 upgrade if you will experience some errors. Just remember, there is always a solution to a problem.