Author Topic: mod_multilingual dropdown  (Read 572 times)

Offline crnogorac081

  • Posts: 1876
  • Gender: Male
mod_multilingual dropdown
« on: February 02, 2018, 04:43:29 PM »
In 2.11 (RC) I see mod_multilingual with tons of code.. I see tons of code but here is simple language switcher. It is made for bootstrap, as dropdown menu, it shows current menu, and on hover/click shows other languages (flags)

Code: [Select]
function feLanguageDropdown($page_id = '') {
global $database;
global $wb;

// Set Flags dir
$flags_dir = MEDIA_DIRECTORY.'/flags/';

$current_lng = $database->get_one("SELECT language FROM `".TABLE_PREFIX."pages` WHERE page_id='$page_id' ");
$page_code = $database->get_one("SELECT page_code FROM `".TABLE_PREFIX."pages` WHERE page_id='$page_id' ");
$ql = $database->query("SELECT DISTINCT(language) FROM `".TABLE_PREFIX."pages` WHERE language != '$current_lng' ORDER BY page_id ASC");
$output = '
<ul id="top_lng" class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">';
if (file_exists(WB_PATH.$flags_dir.strtolower($current_lng).'.png')) {
$output .= '<img src="'.WB_URL.$flags_dir.strtolower($current_lng).'.png" alt="'.$current_lng.'" title="'.$current_lng.'" />'.($ql->numRows() > 0 ? '<span class="caret"></span>' : '');
} else {
$output .= $current_lng.($ql->numRows() > 0 ? ' <span class="caret"></span>' : '');
}
$output .= '
</a>';
if ($ql->numRows() > 0) {
$output .= '
<ul class="dropdown-menu">';
while ($l = $ql->fetchRow()) {
$lng = $l['language'];
$link = $database->get_one("SELECT link FROM `".TABLE_PREFIX."pages` WHERE language = '$lng' AND page_code = '$page_code' ");
if (file_exists(WB_PATH.$flags_dir.strtolower($lng).'.png')) {
$flag = '<img src="'.WB_URL.$flags_dir.strtolower($lng).'.png" alt="'.$lng.'" title="'.$lng.'" />';
} else {
$flag = $lng;
}

$output .= '
<li><a href="'.WB_URL.$link.'/">'.$flag.'</a></li>';
}
$output .= '
</ul>';
}
$output .= '
</li>
</ul>';


return $output;
}


no bb in signature

 

postern-length