WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: kirk on April 18, 2009, 02:42:21 PM

Title: multilingual with several menus tutorial for show menu2
Post by: kirk on April 18, 2009, 02:42:21 PM
Here's a guide to the eternal theme: Multilingual site with several menus as I realized on my website. I'm content with it. Thanks to Hans for the translation.

www.micro-agentur.de

There is a horizontal main menu, a vertical menu for the SUBLEVEL of the main menu, and a footer menu. The aim is that the footer menu reflects the selected language. The language choice is not called with show_menu2 but coded in the template. But more on that later.

Requirement is a WB 2.7 installation with show_menu2

In the backend of WB you have to choose the option to have several menus.

Define an ID and a name for the second footer menu in the info.php of the template:


Code: [Select]
// Definition of the menu-elements (if more than one 1 menu is used)

$menu[1]    = 'Mainnavigation';
$menu[2]    = 'Footernavigation';

In index.php call the horizontal main navigation level1 this way:

Code: [Select]
<?php show_menu2(1SM2_ROOT+1SM2_START); ?>

For level 2 of the main navigation as I use on my site in a vertical form, use this code:

Code: [Select]
<?php show_menu2(1SM2_ROOT+2SM2_START); ?>

The Footer navigation is invoked as:

Code: [Select]
<?php  // Submenu
    
show_menu2(2$wb->page[&#39;root_parent&#39;], SM2_ALL,
        
SM2_ALL SM2_PRETTY); ?>


Now, in the backend a page tree can be created for each language. For example DE and EN.
Each language gets a home page that is realized as a "Menu Link" type. Each additional page in this branch (language) is a sub-level of the "Menu Link" page which we called DE and EN.
Important: The "Menu Link" pages must first be created so that the URL calls the correct language tree , in this case DE - Start

-DE (Main navigation root level)
 - Start (Main navigation level 1 subpage of DE)
  - GermanPage 1 (Main navigation level 2 subpage of Start)
  - GermanPage 2 (Main navigation level 2 subpage of Start)
  - GermanPage 3 (Main navigation level 2 subpage of Start)

-EN (Main navigation root level)
 - Home (Main navigation level1 subpage of EN)
 - EnglishPage 1 (Main navigation level 2 subpage of Home)
 - EnglishPage 2 (Main navigation level 2 subpage of Home)
 - EnglishPage 3 (Main navigation level 2 subpage of Home)

-Kontact (Footernavigation subpage of DE)
-Impressum (Footernavigation subpage of DE)

-Contact (Footernavigation subpage of EN)
-Disclaimer (Footernavigation subpage of EN)

Now we miss the menu to choose a language. That menu isn't called with a show_menu2 menu but coded in the index.php of the template with this code:

Code: [Select]
<a href="http://yourdomain/pages/de/start.php"><img src="<?php echo TEMPLATE_DIR?>/img/deflag.jpg" alt="DEUTSCH" border="0" /></a>
<a href="http://yourdomain/pages/en/home.php"><img src="<?php echo TEMPLATE_DIR?>/img/enflag.jpg" alt="ENGLISH" border="0" /></a>

The language associated flags are in the img folder of the template. Of course one can also choose to use pure text links.

That's it.

I had to bite myself a long time through the many posts on this topic and hope to help you with this little tutorial.
I'm not a coder and my guide is not an ultimate solution, but at least it works for me this way.

Kirk
Title: Re: multilingual with several menus tutorial for show menu2
Post by: klok_pm on August 11, 2009, 11:56:37 AM
This is really a great sollution! Thanks!

I think this also should be explained in the official documentation:
http://help.WebsiteBaker.org/pages/en/advanced-docu/designer-guide/multilingual-websites.php
Anyone. .anyways! Thanks.
Title: Re: multilingual with several menus tutorial for show menu2
Post by: doc on August 11, 2009, 08:10:01 PM
@Kirk:
Thanks for your good work.
Maybe one could add some more information about the usage of a intro page and the possibility to switch a displayed page into another language by using a snippet.

Intro page:
Enable this feature via the WB settings. A intro page can be used to redirect a visitor to the start page in his preferred language by evaluating the defined browser language. The code to put in the intro.php file can be downloaded from here (http://techpatterns.com/downloads/php_language_detection.php). Simple put the code to the intro.php page and invoke the script by adding the function call get_languages('header');.

Remember to define the start page for each language you want to support. DonĀ“t forget to define a default language, which is displayed when the browser language is not supported (lines 106, 110, 122).
Possible values: $location = 'http://yourdomain.com/pages/en/home.php' ...

Language flags:
Can also be created with show_menu2 with the following code (from German Help site (http://help.WebsiteBaker.org/pages/de/advanced-doku/designer-guide/mehrsprachige-webseiten.php#anker3))
Code: [Select]
show_menu2(1, SM2_ROOT, SM2_START+0, SM2_TRIM|SM2_PRETTY,
   '<a href="[url]">' .
   '<img src="' . WB_URL . '/media/flags/[menu_title].gif" alt="[menu_title]"/>' .
   ' [menu_title]</a>', '', '', '', false, false);

Another option, which allows to switch a displayed page to another language when clicking on a language flag is shown here (https://forum.WebsiteBaker.org/index.php/topic,14015.msg91756.html#msg91756). The option requires the installation of an additional code snippet. In addition you must maintain identical page trees as explained in the README.

But also without these additions, your small tutorial is a great contribution.

Regards Doc
Title: Re: multilingual with several menus tutorial for show menu2
Post by: Vincent on March 15, 2010, 10:03:11 AM
Thanks for this solution, Kirk. I tried a long time before finding your post.

Super.
Vincent