Skip to content

Commit

Permalink
Added Multilanguage associations to the TOS linked article in user pr…
Browse files Browse the repository at this point in the history
…ofile… (#9961)

* Added Multilanguage feature to the TOS linked article in user profile plugin

* Fix code formatting errors
  • Loading branch information
mannybiker authored and rdeutz committed May 2, 2016
1 parent 9b75278 commit a6b07a2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions plugins/user/profile/fields/tos.php
Expand Up @@ -88,13 +88,28 @@ protected function getLabel()

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id, alias, catid')
$query->select('id, alias, catid, language')
->from('#__content')
->where('id = ' . $tosarticle);
$db->setQuery($query);
$article = $db->loadObject();
$slug = $article->alias ? ($article->id . ':' . $article->alias) : $article->id;
$url = ContentHelperRoute::getArticleRoute($slug, $article->catid);

if (JLanguageAssociations::isEnabled())
{
$tosassociated = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $tosarticle);
}

$current_lang = JFactory::getLanguage()->getTag();

if ($current_lang != $article->language && array_key_exists($current_lang, $tosassociated))
{
$url = ContentHelperRoute::getArticleRoute($tosassociated[$current_lang]->id, $tosassociated[$current_lang]->catid);
}
else
{
$slug = $article->alias ? ($article->id . ':' . $article->alias) : $article->id;
$url = ContentHelperRoute::getArticleRoute($slug, $article->catid);
}

$link = JHtml::_('link', JRoute::_($url . '&tmpl=component'), $text, $attribs);
}
Expand Down

0 comments on commit a6b07a2

Please sign in to comment.