PHP Joomla! 6 Joomla! 5 Joomla! 3 (Legacy) Helper / API Intermediate

Query Multilingual Item Associations with Associations::getAssociations()

Retrieves linked translations of an article or custom item to generate hreflang links or direct language switch buttons.

Updated on 24 November 2026 33 copies 125 views
components/com_example/src/Helper/AssociationHelper.php
<?php

declare(strict_types=1);

use Joomla\CMS\Language\Associations;

$associated = Associations::getAssociations(
    'com_content',
    '#__content',
    'com_content.item',
    (int) $articleId,
    'id',
    'alias',
    'catid'
);

foreach ($associated as $langTag => $row) {
    // $row->id já vem como "id:alias"
    echo $langTag . ' => ' . $row->id . "\n";
}
Returns each associated item slug ready for RouteHelper.
components/com_example/src/Helper/AssociationHelper.php
<?php
$associated = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $articleId);
Legacy Joomla 3 version via JLanguageAssociations::getAssociations().

Technical explanation and best practices

On multilingual Joomla sites with associations enabled, Associations::getAssociations() queries #__associations and returns an array keyed by language tag (e.g. pt-BR, en-GB).

Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.