Hide language selection from switcher by user access levels

General questions regarding the use of languages in Joomla! 2.5.
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
chirwad
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Aug 17, 2009 10:58 am

Hide language selection from switcher by user access levels

Postby chirwad » Wed Feb 01, 2012 12:08 pm

Hi,

Im stuck, we have a site that is translated into 10 different languages at the moment and is live on Joomla 1.7.4. Our issue is we would like to add 3 more language options to the language switcher but can only be see by registered users. i.e. public users will not be able to see the new languages in the switcher. We need this for development reasons as we have no way of seeing how the pages look like on the site without the general public seeing them aswell.

P.S. I remember Joomfish had this option of assigning user levels to languages, allowing our web designers to work on ans see the hidden languages before pushing them live.

Cheers

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 17944
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Hide language selection from switcher by user access lev

Postby infograf768 » Wed Feb 01, 2012 3:44 pm

I am afraid the only solution at this stage would be to code a new mod_languages looking for the Access level of the specific language home page and the User Group of the user.
Jean-Marie Simonet / infograf · http://www.info-graf.fr
Multilanguage in 2.5: http://help.joomla.org/files/EN-GB_multilang_tutorial.pdf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

chirwad
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Mon Aug 17, 2009 10:58 am

Re: Hide language selection from switcher by user access lev

Postby chirwad » Mon Feb 06, 2012 10:32 am

That is a real shame. Are there any plans to implement this into future releases of Joomla? I think this is the only thing that is missing from the multilingual functionality of Joomla core. The ability to have user level selection on languages in the language manager would solve this issue all together.

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 17944
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Hide language selection from switcher by user access lev

Postby infograf768 » Mon Feb 06, 2012 3:36 pm

There are no plans but anyone may propose a patch.
Jean-Marie Simonet / infograf · http://www.info-graf.fr
Multilanguage in 2.5: http://help.joomla.org/files/EN-GB_multilang_tutorial.pdf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 17944
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Hide language selection from switcher by user access lev

Postby infograf768 » Tue Feb 21, 2012 8:55 am

Update:
This feature is now implemented in trunk and will be available in 2.5.2

See: http://joomlacode.org/gf/project/joomla ... m_id=28036
Jean-Marie Simonet / infograf · http://www.info-graf.fr
Multilanguage in 2.5: http://help.joomla.org/files/EN-GB_multilang_tutorial.pdf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

starfishcd
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Apr 15, 2010 9:26 pm

Re: Hide language selection from switcher by user access lev

Postby starfishcd » Wed Mar 07, 2012 2:42 pm

Hi chirwad

Here's how I filter languages, using the my Language dropdown module hack on J1.7

Backup, Backup, Backup the file default.php in the /modules/mod_languages/tmpl/

I've stripped out the fancy versions of this menu, it only works with a drop down list.

Replace code with the following:

Code: Select all

<?php
/**
 * @version      $Id: default.php 22372 2011-11-09 16:47:59Z github_bot $
 * @package      Joomla.Site
 * @subpackage   mod_languages
 * @copyright   Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
 * @license      GNU General Public License version 2 or later; see LICENSE.txt
 */

// no direct access
defined('_JEXEC') or die('Restricted access');
JHtml::_('stylesheet', 'mod_languages/template.css', array(), true);
?>
<div class="mod-languages<?php echo $moduleclass_sfx ?>">
<?php if ($headerText) : ?>
   <div class="pretext"><p><?php echo $headerText; ?></p></div>
<?php endif; ?>

<?php if ($params->get('dropdown',1)) : ?>
   <form name="lang" method="post" action="">
   <select class="inputbox" onchange="document.location.replace(this.value);" >
<?php
$filterOutKeys = array( '5' );
$filteredArr = array_diff_key( $list, array_flip( $filterOutKeys ) );
print_r($filteredArr);
?>
<?php foreach($filteredArr as $language):?>
      <option dir=<?php echo JLanguage::getInstance($language->lang_code)->isRTL() ? '"rtl"' : '"ltr"'?> value="<?php echo $language->link;?>" <?php echo $language->active ? 'selected="selected"' : ''?>>
      <?php echo $language->title_native;?></option>
   <?php endforeach; ?>
   </select>
   </form>
   <?php endif; ?>

</div>


At the end you can add a manual redirect to another site if needed ( add lines of code after the "<?php endforeach; ?>"

Code: Select all

   <?php endforeach; ?>
    <option value="http://www.example.fr">Français</option>
    <option value="http://www.example.it/">Italiano</option>
   </select>
   </form>
   <?php endif; ?>

</div>


Make the language content live in the control panel then check the source code of the page to get the Array ID of the language you want to remove.

Example below: Array ID is "[0] =>".

Code: Select all

Array
(
    [0] => stdClass Object
        (
            [lang_id] => 2
            [lang_code] => de-DE
            [title] => German
            [title_native] => German
            [sef] => de
            [image] => de
            [description] =>
            [metakey] =>
            [metadesc] =>
            [sitename] =>
            [published] => 1
            [ordering] => 0
            [active] => 1
            [link] => /index.php/de/
        )

    [1] => stdClass Object
        (
            [lang_id] => 1
            [lang_code] => en-GB
            [title] => English (UK)
            [title_native] => English (UK)
            [sef] => en
            [image] => en
            [description] =>
            [metakey] =>
            [metadesc] =>
            [sitename] =>
            [published] => 1
            [ordering] => 1
            [active] =>
            [link] => /index.php/en/
        )
    [2] => stdClass Object
        (
            [lang_id] => 3
            [lang_code] => it-IT
            [title] => Italian (IT)
            [title_native] => Italian (IT)
            [sef] => it
            [image] => it
            [description] =>
            [metakey] =>
            [metadesc] =>
            [sitename] =>
            [published] => 1
            [ordering] => 1
            [active] =>
            [link] => /index.php/it/
        )

)


Add this array ID to line 23:-
$filterOutKeys = array( '0', '2');

This would remove German (0) and Italian (2) from the drop down menu.

Once you have the ID's remove line 25 "print_r($filteredArr);" This just prints the Array so you can grab the ID.

So what happens? Well it just simply removes the language(s) from the drop down list. Then it's up to you how you manage the site, I would suggest that you set the homepage to public access level in the menu manager for the hidden c, add a coming soon message on the landing page, with a link back to a live language. Then set all other menu & pages items to higher users levels (Registered or Higher).

You could make the language(s) landing page (Public) all other menu/page (Registered) without the hack if you wanted, but I prefer to hide the unready languages in the drop down menu until ready.

You can then log into the frontend as a registered user and see all the content for the hidden languages by just adding your country code to the URL:
index.php/it/
index.php/de/

Make your you switch back to a visible languages before leaving the site as the cookies might cause you issues.

When your ready to go live, replace the default.php with your original file.

Note: Recheck Array ID when you add new languages it might well change!

It's not pretty but it works. :D

Richard

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 17944
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: Hide language selection from switcher by user access lev

Postby infograf768 » Wed Mar 07, 2012 4:58 pm

It is not advised to hack core.
If one wants to change the default.php, better do it in an override in the template.

Also, this looks extremely complex as full Access control is now in trunk and will be available with 2.5.3 (2.5.2 was a security release i.e. a 2.5.1 + the correction of the vulnerabilities.)
Jean-Marie Simonet / infograf · http://www.info-graf.fr
Multilanguage in 2.5: http://help.joomla.org/files/EN-GB_multilang_tutorial.pdf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group


Return to “Language - Joomla! 2.5”

Who is online

Users browsing this forum: No registered users and 4 guests