Skip to content

Associations not working for com_contact in Language Switcher module #39346

@robbiejackson

Description

@robbiejackson

Steps to reproduce the issue

Set up the Joomla instance as multilingual, eg French and English, and ensure the Language Switcher module is published.
Define language-specific com_contact categories – eg 'cat-fr' for French and 'cat-en' for English
Define associations to link those categories.
Define language-specific menus, and include a menuitem on each menu pointing to a menuitem of type
Contacts / List Contacts in a Category, and select the category for that language.

So you have something like

  • English menu, with English menuitem pointing to English contact category 'cat-en'
  • French menu, with French menuitem pointing to French contact category 'cat-fr'
  • The English and French categories set as Associations of each other.

On the front-end click on eg the English menuitem to show the English category.
Then click on the French flag in the language switcher.

Expected result

You get routed to the French category equivalent.

Actual result

You stay on the English category page.

System information (as much as possible)

Joomla v4.2.5

Additional comments

I'm pretty sure that the problem is that in administrator\components\com_categories\src\Helper\CategoryAssociationHelper.php, in getCategoryAssociations it has

$helperClassname = ucfirst(substr($extension, 4)) . 'HelperRoute';
…
if (class_exists($helperClassname) && \is_callable(array($helperClassname, 'getCategoryRoute'))) {
      $return[$tag] = $helperClassname::getCategoryRoute($item, $tag, $layout);
} else {
…

The $helperClassname is not being found and so the com_contact getCategoryRoute method is not called.

The same problem doesn't occur for com_content because it has in libraries\extensions.classmap.php the line:

JLoader::registerAlias('ContentHelperRoute', '\\Joomla\\Component\\Content\\Site\\Helper\\RouteHelper', '5.0');

When I inserted a similar line into that file for com_contact:

JLoader::registerAlias('ContactHelperRoute', '\\Joomla\\Component\\Contact\\Site\\Helper\\RouteHelper', '5.0');

it all worked ok.

For comparison, the getCategoryRoute method is also called from plugins\finder\categories\categories.php, in the index function, (where it looks for the method in both the RouterHelper class and the helpers/route.php file), and from getItemRoute in components\com_tags\src\Helper\RouteHelper.php.

It would make sense to have a common approach for finding this getCategoryRoute method.

Note also that this problem probably occurs with other Joomla components which support categories (excepting com_content).

See also Improve how ContentHelperRoute is registered .

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions