WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.9 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • mod_multilingual call without flags?
  • Print
Pages: [1]   Go Down

Author Topic: mod_multilingual call without flags?  (Read 12919 times)

Offline Roych

  • Betatester
  • **
  • Posts: 573
  • Gender: Male
mod_multilingual call without flags?
« on: April 28, 2016, 09:57:24 AM »
Hello


I wan't to call the languages in my template but without the Flag images I want it to be the menu_title name. expl: EN, DE, ...
I tried
Code: [Select]
<?php if(function_exists('language_menu')){ language_menu('[menu_title]'); } ?> not working, not realy sure if it's the right place to add this [menu_title].


I always used the flags so not really sure how to achieve this ... :|


Thank you
R
Logged

Offline jacobi22

  • Betatester
  • **
  • Posts: 5921
Re: mod_multilingual call without flags?
« Reply #1 on: April 28, 2016, 06:20:34 PM »
simple Solution: use a non-image-extension in the function-call like
Code: [Select]
<?php if(function_exists('language_menu')) { language_menu('txt'); } ?>it replace only the file extension from the menu code and show's the ALT-Text from the image (not W3C-valide!!)

better solution: replace the function set_language_icon() with the same name in modules / mod_multilingual / lang.functions.php

Code: [Select]
<?php  //for colored code only, dont copy this line
function set_language_icon ($pageId = 0, $ext='gif' )
{
    if (!
preg_match("/jpg|png|gif|svg|txt|TXT/", $ext)) $ext='gif';
    
$return_value = array();
    
$mod_path = dirname(__FILE__);
    
$mod_rel = str_replace($_SERVER['DOCUMENT_ROOT'],'',str_replace('\\', '/', $mod_path ));
    
$mod_name = basename($mod_path);

    
$array = get_page_languages();
    
$array2= get_pageCode_values( $pageId );
    
$langPageArray = array_merge($array , $array2);

    foreach( 
$langPageArray as $key=>$value )
    {
        
$langKey = $key;
        if(
$array[$langKey]['visibility'] == 'hidden') {continue;}
        
$page_title = get_languages($langKey);
        
$langUrl = get_page_url( $value);
        
$class = strtoupper($langKey) == LANGUAGE ? 'class="current"' : ' class="default"';
        
$return_value [ $langKey ] = "\t\t".'<a '.$class.' href ="'. $langUrl .'" title="'.$page_title.'" >'.PHP_EOL;
        
$return_value [ $langKey ] .= "\t\t\t".'<span>';
        if (
$ext=='TXT'){
            
$return_value [ $langKey ] .=  " $page_title " ;
        } else if (
$ext=='txt'){
            
$return_value [ $langKey ] .=" $langKey " ;
        } else {
            
$return_value [ $langKey ] .= PHP_EOL."\t\t\t\t".'<img src="'.WB_URL.'/modules/'.$mod_name.'/flags/'.strtolower( $langKey ).'.'.$ext.'" alt="'.$page_title.'" title="'.$page_title.'" />'.PHP_EOL."\t\t\t";
        }
        
$return_value [ $langKey ] .= '</span>'.PHP_EOL."\t\t".'</a>'.PHP_EOL;
    }
    return 
$return_value;
}
}

now you have different way's to call the language menu

1. Extension == txt - Result is the language Key like DE EN as your menu
Code: [Select]
<?php if(function_exists('language_menu')) { language_menu('txt'); } ?>
2. Extension == TXT - Result is the page titel of the first page in every avaiable language like  Deutsch English as your menu
Code: [Select]
<?php if(function_exists('language_menu')) { language_menu('TXT'); } ?>
3. Extension == gif - Result are the flags of the first page in every avaiable language like  as your menu with gif-files
Code: [Select]
<?php if(function_exists('language_menu')) { language_menu('gif'); } ?>
3. Extension == png - Result are flags of the first page in every avaiable language like  as your menu, but with png-files
Code: [Select]
<?php if(function_exists('language_menu')) { language_menu('png'); } ?>
the function set_language_icon()  allowed also jpg-files and svg-files. but for this file extension, you have to add a flag-set into folder  modules / mod_multilingual / flags

P.S. Code is part of the next module version
Logged

Offline Roych

  • Betatester
  • **
  • Posts: 573
  • Gender: Male
Re: mod_multilingual call without flags?
« Reply #2 on: April 28, 2016, 08:52:36 PM »
Wow, you are awesome, working exactly how I need it.  (Y)


Thank you very much
R
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • mod_multilingual call without flags?
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2