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
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.
You get routed to the French category equivalent.
You stay on the English category page.
Joomla v4.2.5
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 .
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
@brianteeman hmm, it's definitely failing here! I've just reconfigured it again from scratch on a clean install of 4.2.5.
Just to confirm, you configured the associations between the contact categories, rather than between the menuitems, yes?
(sorry, it's the only explanation I can think of to account for the difference).
ah - yes I made the association between menu items as I always do.
I can confirm that if you also associate the categories then it does not work
I can also confirm that adding the ContactHelperRoute in the helperroute resolves that
@robbiejackson Would you like to make a pull request with your suggested change?
I've never made a pull request to Joomla, so I'd need to sort out how to do that. Also I'm currently focussing on preparing material for the next step of the Joomla MVC tutorial which I'm planning to be how to upgrade to Joomla 4, and that will take some time. So if this issue is still unresolved in a couple of months time I'll give it a go.
That being said, I think that there are a few possibilities for how to address the issue, each with some drawbacks.
1 Include the line eg
JLoader::registerAlias('ContactHelperRoute', '\\Joomla\\Component\\Contact\\Site\\Helper\\RouteHelper', '5.0');
in libraries\extensions.classmap.php
for each of the other Joomla components which use categories.
Drawback is that this option isn't open to 3rd party component developers.
2 Search for the file helpers/route.php
, as in the finder plugin:
JLoader::register($class, JPATH_SITE . '/components/' . $extension . '/helpers/route.php');
but this prolongs a non-namespaced solution, which I believe the Joomla team would not want to do.
3 Search for the namespaced class, as in the finder plugin also:
$class = 'Joomla\\Component\\' . $extension . '\\Site\\Helper\\RouteHelper';
however this doesn't solve the problem for the 3rd party components.
4 Go through the extension load and boot process for the extension, and point to the RouteHelper
method somehow in the component Extension class.
This does seem to me rather over the top (and so expensive in terms of resources) for what's needed.
My preference among the alternative solutions I've though of so far is to include the $namespace
as an additional parameter to the getCategoryAssociations
method in the file administrator\components\com_categories\src\Helper\CategoryAssociationHelper.php
and then look for the class
$helperClassname = trim($namespace, '\\') . '\\' . ucfirst($application->getName()) . '\\Helper\\RouteHelper';
and if the namespace isn't passed in then assume as default
$helperClassname = 'Joomla\\Component\\' . $extension . '\\Site\\Helper\\RouteHelper';
I think these both would then be found by the autoloader.
It may then be possible to remove the line
JLoader::registerAlias('ContentHelperRoute', '\\Joomla\\Component\\Content\\Site\\Helper\\RouteHelper', '5.0');
from libraries\extensions.classmap.php
but I'm not totally sure.
I think the solution needs to be agreed by someone with a more complete understanding of Joomla than I have.
@robbiejackson Thanks for your feedback. I hope it won’t take us a couple of months until we have fixed that’s issue, but if so, we‘d come back to your offer. ;-)
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2022-12-05 10:49:11 |
Closed_By | ⇒ | joomdonation |
can not confirm
chrome_2022-12-02_21-55-44.mp4