32 Posts
sUrfa
9 years ago
1
Topic

Hi everyone,

in the past I faced a little issue in one of my sites.

Situation: 

  • The site uses the Joomla 3 multilingual features and a module "Language Switcher" to change the language.
  • I configured Seblod to be multilingual too (JText) and setup a content type "products" with Checkboxes, etc.
  • The problem I had was, that in an article the language switcher would redirect to the right Itemid, but not the article

To solve this problem I did the following

  • created an override for "mod_languages" and selected the override in the language switcher module
  • added the following code on top

$jinput = JFactory::getApplication()->input;
if ($jinput->getString('option') == 'com_content' && $jinput->getInt('id') && $jinput->getInt('Itemid') == --menu-Itemid-where-override-should-be-active--) {
   $articleId = preg_replace('/-/', ':', substr(strrchr(JUri::current(), "/"), 1), 1);
   foreach ($list as $language) {
     if (!$language->active) {
     $language->link = JRoute::_("index.php?view=article&id=" . $articleId . "&Itemid=" . --language-associated-menu-item-- . "&lang=" . $language->sef);
     }
   }
}

This change is not only helpful for the users to change the language and not lose track, but also for search engines if the "hreflang" property is set in the Language Switcher module.

Hope this is helpful for you!

What do you think?

Best Regards

sUrfa

Get a VIP membership
215 Posts
iliil
7 years ago
0
Level 1

Hello sUrfa

Thanks for this!

I was always wondering why this problem is not solved in core Joomla. If an article is enabled for all languages and has no associations, the language switcher should change the language without any redirection.

Your solution works..

Michal

Get a Book for SEBLOD