2

I have a question about the Joomla language switcher module. I would like to hide the option to switch to English language on the website. I can't unpublish the English language because then it says the English site doesn't exist anymore. But I need it to exist because its accessed from different link.

enter image description here

  • thinking ... hmmm, then what is the point to have a link for the current language on the website... I mean that from your description people will already seeing the Hrvatski version of the website, why to have a language selection for the same language? – FFrewin Nov 26 '14 at 9:40
  • Default language is Slovenian-SI, but i also need option for Hrvatski-HR. I cant unpublish English-UK because the entire English site stops working. So basicly SI/HR are accessed from same link, EN version is accessed from entierly diffrent link. www.aeq.si <- SI/HR somatics.si <- EN only – Matthew Nov 27 '14 at 17:17
2
  1. Copy the file modules\mod_languages\tmpl\default.php to templates\YOURTEMPLATE\html\mod_languages\default.php to create a template override for the language module.
  2. Locate the following line in your template override (aprox. line 32 in Joomla 3.3):

    <li class="<?php echo $language->active ? 'lang-active' : '';?>" dir="<?php echo JLanguage::getInstance($language->lang_code)->isRTL() ? 'rtl' : 'ltr' ?>">
    

    Replace with this (adding echo $language->title_native;):

    <li class="<?php echo $language->active ? 'lang-active' : ''; echo ' ' . $language->lang_code; ?>" dir="<?php echo JLanguage::getInstance($language->lang_code)->isRTL() ? 'rtl' : 'ltr' ?>">
    

    This will add the language code to the <li> tags, giving you <li class="active en-GB"... and allow you to target any language using CSS.

  3. Finally, add this code to your template's CSS stylesheet (replace en-GB with the language you want to hide):

    .en-GB {
        display: none!important;
    }
    
  • the quick way of hiding things on the browser – FFrewin Nov 25 '14 at 19:42
  • Yes @FFrewin, using CSS in this case is a "quick-and-dirty" solution, yours is a bit more advanced. – johanpw Nov 25 '14 at 20:17
  • in what folder do i create css file and what filename do i give it ? Im am new to joomla – Matthew Nov 25 '14 at 22:18
  • That depends on your template. I recommend you take a look at this post for more details on how to add custom CSS code to your template. – johanpw Nov 25 '14 at 22:24
  • Ok i did all those things, now how do i override the template, do i have to check something in CMS ? – Matthew Nov 25 '14 at 22:50
1

Following Anibal's answer and the link on how to create a module template override or alternative layout... here is a piece of code you could use inside the template file of the languages module.

The template of the module is checking for the settings you have defined in the module manager, about how to display the languages.

Part of code is like this:

    <?php if ($params->get('show_active', 0) || !$language->active):?>

        <li class="<?php echo $language->active ? 'lang-active' : '';?>" dir="<?php echo JLanguage::getInstance($language->lang_code)->isRTL() ? 'rtl' : 'ltr' ?>">
        <a href="<?php echo $language->link;?>">
        <?php if ($params->get('image', 1)):?>
            <?php echo JHtml::_('image', 'mod_languages/' . $language->image . '.gif', $language->title_native, array('title' => $language->title_native), true);?>
        <?php else : ?>

                <?php echo $params->get('full_name', 1) ? $language->title_native : strtoupper($language->sef);?>

        <?php endif; ?>
        </a>
        </li>
    <?php endif;?>
<?php endforeach;?>

It uses foreach loop, to loop through the available content languages and will display them. Inside the foreach loop and right after its beginning and before its end, you can wrap the executed code with a conditional check like below:

This goes after the beginning of the foreach loop:

<?php if ($language->lang_code != 'en-GB') {?>

This will make the code that renders the language menus, only if the language of the menu is not english.

This closes and wrap your if statement, just before the closing of the foreach loop.

<?php } ?>

So you should end up with something like this:

<?php foreach ($list as $language) : ?>
    <?php if ($language->lang_code != 'en-GB') {?> // Don't run if it's english.
    <?php if ($params->get('show_active', 0) || !$language->active):?>

        <li class="<?php echo $language->active ? 'lang-active' : '';?>" dir="<?php echo JLanguage::getInstance($language->lang_code)->isRTL() ? 'rtl' : 'ltr' ?>">
        <a href="<?php echo $language->link;?>">
        <?php if ($params->get('image', 1)):?>
            <?php echo JHtml::_('image', 'mod_languages/' . $language->image . '.gif', $language->title_native, array('title' => $language->title_native), true);?>
        <?php else : ?>

                <?php echo $params->get('full_name', 1) ? $language->title_native : strtoupper($language->sef);?>

        <?php endif; ?>
        </a>
        </li>
    <?php endif;?> 
            <?php } ?>

<?php endforeach;?>
0

You can create a new module layout, showing only the languages you need.

Module Alternative Layouts http://docs.joomla.org/Layout_Overrides_in_Joomla#Module_Alternative_Layouts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.