Hi Arno,
I would like to report a multilingual routing issue in jDownloads 4.1.7.
The problem affects both the association link rendered by jDownloads and Joomla's Language Switcher module (mod_languages).
Environment:
- Joomla 6.1.3
- jDownloads 4.1.7 Stable
- Helix Ultimate 2.2.10
- Multilingual site: Spanish (es-ES, default) and English (en-GB)
- Joomla multilingual associations enabled
PROBLEM
The downloads, their categories, and the corresponding Joomla menu items are associated between Spanish and English.
For example:
Spanish download:
ID: 740
Category: 100
Language: es-ES
Correct URL:
https://alamarte.com/descargas/extensiones/plugins/helix-language-fix/download/100-plugins/740-alamarte-helix-language-fix
Associated English download:
ID: 1295
Category: 142
Language: en-GB
Correct URL:
https://alamarte.com/en/downloads/extensions/plugins/helix-language-fix/download/142-plugins/1295-alamarte-helix-language-fix
However, when viewing the English download, the association generated by jDownloads was:
/downloads/extensions/plugins/helix-language-fix/download/100-plugins/740-alamarte-helix-language-fix
This URL contains the Spanish download and category, but retains the English menu route:
/downloads/
The correct Spanish URL is:
/descargas/extensiones/plugins/helix-language-fix/download/100-plugins/740-alamarte-helix-language-fix
The opposite happened when viewing the Spanish download.
jDownloads generated:
/en/descargas/extensiones/plugins/helix-language-fix/download/142-plugins/1295-alamarte-helix-language-fix
instead of:
/en/downloads/extensions/plugins/helix-language-fix/download/142-plugins/1295-alamarte-helix-language-fix
In other words, the generated association contained:
- the destination download ID;
- the destination category ID;
- the destination language;
- but the Itemid / menu route from the source language.
These mixed-language URLs returned HTTP 404.
TWO DIFFERENT FRONTEND OVERRIDES WERE USED TO DIAGNOSE AND WORK AROUND THE ISSUE
No jDownloads core file was modified.
Both overrides are located under the Helix Ultimate template, but they have different purposes.
1. jDOWNLOADS DOWNLOAD LAYOUT OVERRIDE
Location:
/templates/shaper_helixultimate/html/com_jdownloads/download/default.php
This override already existed on the site because the jDownloads Download Details layout is customized.
During the multilingual investigation, I added a correction to the association URL rendered by this layout.
The correction obtains the Joomla menu item associated with the destination language and replaces the incorrect source-language Itemid before routing the association URL.
This fixed the visible jDownloads:
"Also available in"
association link.
For example, from the English download, the Spanish association changed from:
/downloads/extensions/plugins/helix-language-fix/download/100-plugins/740-alamarte-helix-language-fix
to the correct:
/descargas/extensiones/plugins/helix-language-fix/download/100-plugins/740-alamarte-helix-language-fix
At this point the association link displayed by jDownloads was correct.
However, a crawler still found the same mixed-language 404 URLs.
I then inspected the complete generated HTML and found another source of the same incorrect URLs.
2. HELIX ULTIMATE OVERRIDE FOR JOOMLA MOD_LANGUAGES
Location:
/templates/shaper_helixultimate/html/mod_languages/default.php
This second override is specifically for Helix Ultimate.
Helix Ultimate 2.2.10 already includes this override file as a small bridge to its own language-module renderer.
The original Helix file contains essentially:
defined('JPATH_BASE') or die();
require HelixUltimate\Framework\Platform\HTMLOverride::loadTemplate();
Therefore I did not replace it with Joomla's standard mod_languages layout.
Instead, I kept Helix Ultimate's normal override mechanism intact and added the jDownloads-specific correction before:
require HelixUltimate\Framework\Platform\HTMLOverride::loadTemplate();
The correction runs only when:
option=com_jdownloads
view=download
It obtains the association route supplied by com_jdownloads, replaces its incorrect Itemid with the Joomla menu Itemid associated with the destination language, assigns the corrected route to $language->link, and then lets Helix Ultimate render mod_languages normally.
This is therefore a Helix Ultimate-specific workaround for mod_languages, not a replacement of Helix's language-selector layout.
WHY THE SECOND OVERRIDE WAS NECESSARY
After fixing the association displayed inside the jDownloads layout, Joomla's Language Switcher module still contained the incorrect URLs.
This was confirmed directly in the generated HTML.
On the English download page, mod_languages still contained:
/downloads/extensions/plugins/helix-language-fix/download/100-plugins/740-alamarte-helix-language-fix
On the Spanish page, it contained:
/en/descargas/extensiones/plugins/helix-language-fix/download/142-plugins/1295-alamarte-helix-language-fix
Therefore the problem was not caused by the jDownloads layout itself.
com_jdownloads was providing the incorrect association route to Joomla's multilingual association system, and mod_languages was rendering the URL it received.
SOURCE CODE
I traced the download association generation to:
components/com_jdownloads/src/Helper/AssociationHelper.php
For a download association it calls:
RouteHelper::getDownloadRoute(
$item->id,
(int) $item->catid,
$item->language,
$layout
);
Then, in:
components/com_jdownloads/src/Helper/RouteHelper.php
getDownloadRoute() correctly adds the destination language:
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}
However, the destination language is not used when the Itemid is selected.
_findItem() contains:
$language = isset($needles['language']) ? $needles['language'] : '*';
but getDownloadRoute() does not provide the destination language to the menu-item lookup.
As a consequence, _findItem() can accept the currently active jDownloads menu item from the source language.
The resulting route can therefore contain:
- destination download;
- destination category;
- destination language;
- source-language Itemid.
TEST RESULTS
Before applying the workarounds, a clean crawl consistently detected 12 mixed-language HTTP 404 URLs.
They corresponded to six Spanish/English download pairs.
After correcting:
1. the association rendered by the jDownloads download layout; and
2. the association used by mod_languages through the Helix Ultimate-specific override,
10 of the 12 incorrect URLs disappeared.
The remaining two belonged to the Spanish/English Alamarte Breadcrumbs pair.
I then discovered that those two Joomla menu items had accidentally been left without a multilingual menu association.
All the other tested menu pairs were correctly associated.
After restoring the missing Breadcrumbs menu association and running another clean crawl, the final two incorrect URLs also disappeared.
Final result:
12 of 12 mixed-language 404 URLs disappeared.
The final crawl detected no broken links related to this multilingual routing problem.
This also confirmed that, when the Joomla menu associations are correctly configured, replacing the source-language Itemid with the Itemid associated with the destination language resolves the routing problem.
RELATED OLD REPORT
I also found this older forum topic:
"Error in Itemid reference between two languages"
https://www.jdownloads.com/forum/index.php?topic=13763.0
It appears to describe a similar multilingual Itemid problem, although it concerns older Joomla and jDownloads versions.
QUESTIONS
Could you please check whether RouteHelper::getDownloadRoute() should explicitly select the Joomla menu Itemid belonging to the destination language when generating a multilingual download association?
It also seems worth reviewing whether the destination language should be taken into account by _findItem() when selecting the menu item for these association routes.
I would also be interested to know whether this routing logic has already been changed in the jDownloads 6 development branch.
If useful, I can provide:
- the original and corrected association URLs;
- the generated HTML showing the incorrect URLs received by mod_languages;
- the jDownloads download-layout workaround;
- the Helix Ultimate-specific mod_languages workaround;
- and the crawler results before and after the corrections.
Regards,
Andrés
Alamarte Ingeniería