Joomla language switcher modification
I tried to change a bit the displaying of may language switcher module. The idea is that to have my language option in a jquery select box and on change to retrieve the site to the selected language. My problem is that is not outputting in the right way the default language and on selection the link is not build it on.
<?php
/**
* @version $Id: default.php 19022 2010-10-02 14:51:33Z infograf768 $
* @package Joomla.Site
* @subpackage mod_languages
* @copyright 开发者_JAVA技巧Copyright (C) 2005 - 2010 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);
$document = &JFactory::getDocument();
$document->addScript('jomres/javascript/jquery.ui.selectmenu.js');
$document->addScript('jomres/javascript/selectmenu.js');
?>
<select name="speedB" id="speedB" onchange="Javascript: window.location.href='<?php echo $language->title;?>'">>
<?php foreach($list as $language):?>
<option value=" <?php echo $language->active ? 'lang-active' : '';?>">
<?php echo $language->title;?>
<?php endforeach;?></option>
</select>
The problem is in how the option tags are displayed. The value attribute should contain a value that will be sent back to the browser, and there's a selected attribute that determines which value will be sent back. Only the attribute which is selected will have its value sent back.
So you would need something like
<?php foreach($list as $language):?>
<option value="<?php echo $language->title;?>" <?php echo $language->active ? 'selected' : '';?>
<?php echo $language->title;?>
</option>
<?php endforeach;?>
Note that I do not have Joomla available so I can't check which field of $language
would be best to use in the option value attribute. There's probably something that provides a short name like en-GB
or fr-FR
精彩评论