Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 06:02:14 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155555 Posts in 21715 Topics by 7737 Members
Latest Member: gx-world
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Multi language website - switch displayed  (Read 1338 times)
Chaploo
Guest
« on: January 09, 2008, 12:09:13 PM »

Hi everyone,

I just created my first multi language website using the (german) documentation http://help.websitebaker.org/pages/de/advanced-doku/designer-guide/mehrsprachige-webseiten.php which is a great source, everything worked fine so far.

My question now is: In the version mentioned above now the links to all languages available are being displayed. What I would like to know is if it's possible that only the link to the other (non-active) languages are displayed (because it's not useful to have a link to "english" if you are already on the eglish site...  smiley

Can anybody help?

Thanks & regards
Jochen
Logged
ruebenwurzel
WebsiteBaker Org e.V.

Offline Offline

Posts: 7973



WWW
« Reply #1 on: January 09, 2008, 01:24:12 PM »

Hello,

simply adapt your menu call to only us the subpages and not the root pages.

Matthias
Logged
Chaploo
Guest
« Reply #2 on: January 09, 2008, 01:35:39 PM »

Hi,

I hope I am not misunderstanding, but in this case didn't mean to hide the pages of the other languages - that works fine the way it is described in the manual. I want to hide the language-choice button / link (the flag or text link) of the active language.

Regards
Jochen
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #3 on: January 09, 2008, 05:48:18 PM »

If you want to hide the Language Selection Links, try following:

Each page has a root_parent which is numerical. Use this together with the menuoutput and a css class to hide the "offending" flag wink

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Chaploo
Guest
« Reply #4 on: January 10, 2008, 02:50:26 PM »

Yes, that's exactly what I had in mind, but ...

could you please explain your idea a little more?   smiley

thanks & regards
Jochen
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #5 on: January 13, 2008, 09:54:10 AM »

OK ... here is the code:

Code:
$page_id = PAGE_ID;
$query_page = $database->query("SELECT root_parent, parent FROM ".TABLE_PREFIX."pages WHERE page_id = $page_id LIMIT 1");
$fetch_page = $query_page->fetchRow();
$root_parent = $fetch_page['root_parent'];
$parent = $fetch_page['parent'];
if ($root_parent == 0){
        $current_parent = $parent; }
    else {
            $current_parent = $root_parent; }
if ($dir = @opendir(WB_PATH.MEDIA_DIRECTORY.'/flags')) {
  while (false !== ($file = readdir($dir))) {
       if (substr($file, 0, 1) != '.' AND $file != 'index.php') {
        $filelist[] = $file;
    }
}
closedir($dir);
}
asort($filelist);

foreach ($filelist as $filename) {
           $pathinfo = pathinfo($filename);
           $language = strtolower(str_replace('.'.$pathinfo['extension'],'',$filename));
           $query_page = $database->query("SELECT root_parent, parent FROM ".TABLE_PREFIX."pages WHERE page_title = '$language' LIMIT 1");
           $fetch_page = $query_page->fetchRow();
           $current_root_parent = $fetch_page['root_parent'];
           $current_parent = $fetch_page['parent'];

           if (($current_root_parent == '0') or ($current_root_parent == '')){
                   $check_parent = $current_parent;}
           if ($root_parent != $check_parent) {
                      $css = '';
           } else {
                      $css = 'display: none;';
           }
           echo '<p style="'.$css.'">';
           echo '<a href="'.WB_URL.PAGES_DIRECTORY.'/'.$language.PAGE_EXTENSION.'">';
           echo '<img src="'.WB_URL.MEDIA_DIRECTORY.'/flags/'.$filename.' " alt="'.$language.'" />';
           echo '</a></p>';
    }

It is not very elegant and at the moment only works for 1 level below the root. Further down in the pages it does not yet work. Explanation:

The code checks for the current page parent and root parent. If the root parent is 0 then it uses the current parent for the check. If the check finds, that the current page parent/root_parent is the same like the language page, it sets the css style to no display. Additionally it sorts the languages by name.

Requirement: It needs to have Flag Files in the folder "flags" under the mediadir which are named the same like the language selection pages.

I invite everybody to work with this code ... and post it (requirement!) ...

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Chaploo
Guest
« Reply #6 on: January 14, 2008, 12:15:55 PM »

Hi Klaus,

thanks for the code!

Unfortunately it does not work yet. I put it that way:

Code:
<body>
<div id="container">

<div id="kopf"><h2><?php page_title('','[PAGE_TITLE]'); ?></h2></div>

<div id="left">
<div id="navi_1"><?php show_menu(11); ?></div>
<div id="sprache">
<?php
$page_id 
PAGE_ID;
$query_page $database->query("SELECT root_parent, parent FROM ".TABLE_PREFIX."pages WHERE page_id = $page_id LIMIT 1");
$fetch_page $query_page->fetchRow();
$root_parent $fetch_page['root_parent'];
$parent $fetch_page['parent'];
if (
$root_parent == 0){
$current_parent $parent; }
else {
$current_parent $root_parent; }
if (
$dir = @opendir(WB_PATH.MEDIA_DIRECTORY.'/flags')) {
while (
false !== ($file readdir($dir))) {
if (
substr($file01) != '.' AND $file != 'index.php') {
$filelist[] = $file;
}
}
closedir($dir);
}
asort($filelist);

foreach (
$filelist as $filename) {
$pathinfo pathinfo($filename);
$language strtolower(str_replace('.'.$pathinfo['extension'],'',$filename));
$query_page $database->query("SELECT root_parent, parent FROM ".TABLE_PREFIX."pages WHERE page_title = '$language' LIMIT 1");
$fetch_page $query_page->fetchRow();
$current_root_parent $fetch_page['root_parent'];
$current_parent $fetch_page['parent'];

if ((
$current_root_parent == '0') or ($current_root_parent == '')){
$check_parent $current_parent;}
if (
$root_parent != $check_parent) {
$css '';
} else {
$css 'display: none;';
}
echo 
'<p style="'.$css.'">';
echo 
'<a href="'.WB_URL.PAGES_DIRECTORY.'/'.$language.PAGE_EXTENSION.'">';
echo 
'<img src="'.WB_URL.MEDIA_DIRECTORY.'/flags/'.$filename.' " alt="'.$language.'" />';
echo 
'</a></p>';
}
?>

</div>
<div id="sprache"><?php show_menu(101true"[a]<img src=" .WB_URL "/media/flags/[menu_title].gif />[/a]"''''''false''0); ?></div>
</div>

<div id="inhalt"><?php page_content(); ?></div>
<div id="footer"></div>
</div>

</body>

(I left the old languages switch underneath for comparison)

Both flags are being displayed.  sad
Could the reason be that my root pages are not named en.php and de.php but home.php and startseite.php?

Regards
Jochen
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6977


WWW
« Reply #7 on: January 14, 2008, 04:01:18 PM »

The Name of the sub-pages  does not matter, important is the language selection page and the structure.

-EN
--Homepage

-DE
--Startseite

...
also the flag files need to be called the same way like the language selection pages ...

3rd ... like I posted above, the code does not yet work in the lower levels ...

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!