How to "Allow language change from any displayed page"?

jsn

Thanks, reading the Page Source of this web site I was able to understand everything
[url="http://www.jsnit.com/"]http://www.jsnit.com/[/url]

LordDarkman

I just took the example code from help. This one is hard coded. Because of the problems I did a step by step with the help without trying to think. (For me it's easy to know what to do, so I tried to do it as a noop.) I started with a new installation (1171), round template. Only tool I used was addon file editor. Everything works.

CU Moritz

doc

Hi,

as true for almost every forum, double posting is not the best thing one can do in a forum :wink:

The code posted by LordDarkman works, but I would change the hardcoded /media/ part in the function call with the WB constant for the media folder and add the function parameter to the function call for better readability (as suggested for show_menu2 call).

The updated function call would look like this:

<?php
show_menu
(
  
$menu_number 1,
  
$start_level 0,
  
$recurse 1,
  
$collapse =  true,
  
$item_template '[a]<img src=' WB_URL MEDIA_DIRECTORY '/flags/[menu_title].gif />[/a]',
  
$item_footer null,
  
$menu_header null,
  
$menu_footer null,
  
$default_class false,
  
$current_class null,
  
$parent null
);
?>



In order to make the code working, you have to:
1) organize your backend page structure as shown on the WB help site (container pages /en ...)
2) create a folder named /flags in your WB media folder
3) place flag icons in this folder (e.g. en.gif, de.gif)
4) add the function call to the body of the index.php file of your template body (remember to wrap by <?php ?>)

Doc

LordDarkman

QuoteTo allow your visitors to change the language from any displayed page, one needs to add an additional show_menu() call function to the index.php file of your template

You need one show_menu(1,0,1) in your template and one show_menu(1, 0, 1, true, "[a]<img src=" .WB_URL .  "/media/flags/[menu_title].gif />[/a]", '', '', '', false, '', 0) for the language. Normaly you put the friest one in the menu and the second one in the header of your template.
The code is working as long you did everything right.
Look into your other treat, there I wrote something about the hole template.

CU Moritz

jsn

Doc,

I am just following the documentation to set up a Multilingal web site.

On step 3:
http://help.websitebaker.org/pages/en/advanced-docu/designer-guide/multilingual-websites.php?searchresult=1&sstring=multilingual#anker3

Section "Allow language change from any displayed page", it gives an example that I am not able to make it work in my case.

This is why I tried something else that matches you example:
http://project.websitebaker2.org/wiki/Docs-EN-Multilingual-Website-Step2

and this code works, but apparently it is an old version.

In you case, will you add the code in the header of the index file or somewhere else?

Thank you for you info.


[url="http://www.jsnit.com/"]http://www.jsnit.com/[/url]

doc

Hi,

Quote from: jsn... And it shows the flags as hyperlinks to the specific home page for each language.
Fine, so keep the working code in your template.

Quote from: jsnBut, if I replace the code above with one of the syntax described in the help:
Do not really understand why you want to replace the working code with code which seems not to work as intented. Result will not change.

Can have different reasons. Maybe the code example on the help site is wrong. Check the code example of the German and/or Dutch help page to check for an error in the function call.

In case of blank screen, the code syntax is most likely wrong. Can be a missing php tag, missing semicolon etc. Activate error reporting during development or changes on your template via WB Options (set to E_ALL). This should provide an error message which cause the page to stop rentering (blank page). Also search the forum for blank page, there are some other hints you may want follow.

Doc

jsn

Doc,

I changed my template to Simple, and added the code from this link:

http://project.websitebaker2.org/wiki/Docs-EN-Multilingual-Website-Step2

which is the same of the one you copy/pasted in the header section on the index.php file. And it shows the flags as hyperlinks to the specific home page for each language.

But, if I replace the code above with one of the syntax described in the help:
<?php
show_menu(1, 0, 1, true, "[a]<img src=" .WB_URL ."/media/flags/[menu_title].gif />[/a]", '', '', '', false, '', 0);
?>

It does not work, one of the options eliminates all the text in the menus, and the other shows the page blank.

So this is my question Doc: where in the index.php file do you recommend to add this function, in the Header, Body, etc?

Regards


[url="http://www.jsnit.com/"]http://www.jsnit.com/[/url]

jsn

[url="http://www.jsnit.com/"]http://www.jsnit.com/[/url]

doc

Hi,

here some very old code which can be placed in the index.php file of a template. The code creates a link to each start page for each icon found in /media/flags. Code was used originally by Ryan in the WB template files if I remember right:
<?php
    $flags_path 
WB_PATH.MEDIA_DIRECTORY.'/flags';
    if(
file_exists($flags_path) AND $handle opendir($flags_path)) {
    
?>

   <div class="wb-flags">
       <table cellpadding="5" cellspacing="0" border="0">
       <tr>
           <td rowspan="5" style="font-weight: bold;" valign="top">
               Language:
           </td>
           <?php
            
while (false !== ($file readdir($handle))) {
                if (
substr($file01) != '.' AND $file != 'index.php') {
                    
$pathinfo pathinfo($file);
                    
$language strtolower(str_replace('.'.$pathinfo['extension'],'',$file));
                    
?>

                   <td>
                       <a href="<?php echo WB_URL.'/pages/'.$language.PAGE_EXTENSION?>">
                           <img src="<?php echo WB_URL.MEDIA_DIRECTORY.'/flags/'.$file?>" alt="<?php echo $language?>" /> <?php echo strtoupper($language); ?>
                       </a>
                   </td>
                   <?php
                
}
            }
            
closedir($handle);
            
?>

       </tr>


However, I think there are more elegant ways to achieve the same, e.g. with show_menu or show_menu2 calls:

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



The show_menu call requires flag icons (.gif) in /media/flags. To use this, you need to organize your pages in a certain way as dicsussed on the help site. Think this shoulb be enough hints for your next steps. Good luck.

Doc

jsn

I did it! And I am doing it! For example after intalling the Add On to manage tempaltes things became more clear!
[url="http://www.jsnit.com/"]http://www.jsnit.com/[/url]

erpe0812

QuoteIf you think that my quesitons are too simple
It is not a question of too simple but a question of effort.
This forum will help you to help yourself.

No one "blames" you that you have just started with WB.
But if you want to build a website and create (or modify) a template you should really read the replies and the posted pages.

erpe


jsn

[url="http://www.jsnit.com/"]http://www.jsnit.com/[/url]

jsn

Erpe,

I am not asking you to build my web site.

To your comment: " this is not the only question where you did not understand the reply."  I am starting using this tool, I just downloaded it this weekend, so I am not familiar wilth alll the terminology. Yestday I posted a question, concerning the location of the Template, and finally with some indicaitons I was able complete my code. I am familiar with other CM such as Joomla.

I am currently reading this web site help, the Multilingual section and I am posting a question because this is not very clear. At least when I follow the indications I do not get the expected result.

I do not understand why you adopt this attitude, as far as I know I did not offend you.  If you think that my quesitons are too simple, please do not respond to them, I hope that someone else will.

Regards

[url="http://www.jsnit.com/"]http://www.jsnit.com/[/url]


erpe0812

Hi

this is not the only question where you did not understand the reply.
I am not willing to build your homepage, cause that was what you asked for in one of your threads.

Read the help-pages, read some stuff about html and css and you can do your hp on your own.
And if then there are some questions left, return to this forum.

rgds

erpe

jsn

I am sorry I do not understand your answer.

This is a copy/paste of the index.php file. Where do I haev to copy this second show_menu?
I want the flags to appear in the header of the page, like in  http://start.websitebaker2.org/en/introduction.php


<?php
/**
* $Id: index.php 1106 2009-08-06 16:07:39Z Ruebenwurzel $
* WebsiteBaker template: round
* This template is one of four basis templates distributed with WebsiteBaker.
* Feel free to modify or build up on this template.
*
* This file contains the overall template markup and the WebsiteBaker
* template functions to add the contents from the database.
*
* LICENSE: GNU General Public License
*
* @author     Ryan Djurovich, C. Sommer
* @copyright  GNU General Public License
* @license    http://www.gnu.org/licenses/gpl.html
* @version    2.70
* @platform   WebsiteBaker 2.7
*
* WebsiteBaker is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* WebsiteBaker is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*/

// prevent this file from being accessed directly
if (!defined('WB_PATH')) die(header('Location: ../../../index.php'));

// TEMPLATE CODE STARTS BELOW
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=<?php
   echo defined('DEFAULT_CHARSET') ? DEFAULT_CHARSET : 'utf-8'; ?>" />
   <meta name="description" content="<?php page_description(); ?>" />
   <meta name="keywords" content="<?php page_keywords(); ?>" />
   <?php
   // automatically include optional WB module files (frontend.css, frontend.js)
   if (function_exists('register_frontend_modfiles')) {
       register_frontend_modfiles('css');
       register_frontend_modfiles('js');
   } ?>
   <link rel="stylesheet" type="text/css" href="<?php
       echo TEMPLATE_DIR; ?>/template.css" media="screen,projection" />
   <link rel="stylesheet" type="text/css" href="<?php
       echo TEMPLATE_DIR; ?>/print.css" media="print" />
   <title><?php page_title('', '[WEBSITE_TITLE]'); ?></title>
</head>

<body>

<table cellpadding="0" cellspacing="0" border="0" align="center" class="main" width="750">
<tr>
   <td colspan="2" class="header" height="80">
       <a href="<?php echo WB_URL; ?>">
           <img src="<?php echo TEMPLATE_DIR; ?>/images/banner.jpg" border="0" width="750" height="80" alt="<?php
           page_title('', '[WEBSITE_TITLE]'); ?>" />
       </a>
   </td>
</tr>
<tr>
   <?php
   // navigation menu
   if(SHOW_MENU) {
   ?>    
   <td style="padding: 10px; background-color: #FFF;" valign="top">
       <table cellpadding="0" cellspacing="0" border="0" width="150" align="center" class="menu">
       <tr>
           <td class="border">
               <img src="<?php echo TEMPLATE_DIR; ?>/images/menu_top.gif" border="0" alt="" />
           </td>
       </tr>
       <tr>
           <td width="170">

<?php show_menu(1, 1); ?>


               
           </td>
       </tr>
       <tr>
           <td class="border">
               <img src="<?php echo TEMPLATE_DIR; ?>/images/menu_bottom.gif" border="0" alt="" />
           </td>
       </tr>
       </table>
       
       
       <!-- frontend search -->
       <?php if (SHOW_SEARCH) { ?>
       <form name="search" action="<?php echo WB_URL; ?>/search/index.php" method="get">
           <input type="hidden" name="referrer" value="<?php
               echo defined('REFERRER_ID') ? REFERRER_ID : PAGE_ID; ?>" />
           <table cellpadding="0" cellspacing="0" border="0" width="150" align="center" style="margin-top: 10px;">
               <tr>
                   <td class="border">
                       <img src="<?php echo TEMPLATE_DIR; ?>/images/menu_top.gif" border="0" alt="" />
                   </td>
               </tr>
               <tr>
                   <td class="login">
                       <input type="text" name="string" />
                   </td>
               </tr>
               <tr>
                   <td class="login">
                       <input type="submit" name="submit" value="<?php echo $TEXT['SEARCH']; ?>" />
                   </td>
               </tr>
               <tr>
                   <td class="border">
                       <img src="<?php echo TEMPLATE_DIR; ?>/images/menu_bottom.gif" border="0" alt="" />
                   </td>
               </tr>
           </table>
       </form>
       <?php } ?>
       
       <?php
       if(FRONTEND_LOGIN AND !$wb->is_authenticated()) {
       ?>
       <form name="login" action="<?php echo LOGIN_URL; ?>" method="post">
           
           <table cellpadding="0" cellspacing="0" border="0" width="150" align="center" style="margin-top: 10px;">
           <tr>
               <td class="border">
                   <img src="<?php echo TEMPLATE_DIR; ?>/images/menu_top.gif" border="0" alt="" />
               </td>
           </tr>
           <tr>
               <td class="login" style="text-transform: uppercase;">
                   <b><?php echo $TEXT['LOGIN']; ?></b>
               </td>
           </tr>
           <tr>
               <td class="login" style="text-align: left;">
                   <?php echo $TEXT['USERNAME']; ?>:
               </td>
           </tr>
           <tr>
               <td class="login">
                   <input type="text" name="username" />
               </td>
           </tr>
           <tr>
               <td class="login" style="text-align: left;">
                   <?php echo $TEXT['PASSWORD']; ?>:
               </td>
           </tr>
           <tr>
               <td class="login">
                   <input type="password" name="password" />
               </td>
           </tr>
           <tr>
               <td class="login">
                   <input type="submit" name="submit" value="<?php
                       echo $TEXT['LOGIN']; ?>" style="margin-top: 3px; text-transform: uppercase;" />
               </td>
           </tr>
           <tr>
               <td class="login">
                   <a href="<?php echo FORGOT_URL; ?>"><?php echo $TEXT['FORGOT_DETAILS']; ?></a>
                   <?php if (is_numeric(FRONTEND_SIGNUP)) { ?>
                       <a href="<?php echo SIGNUP_URL; ?>"><?php echo $TEXT['SIGNUP']; ?></a>
                   <?php } ?>
               </td>
           </tr>
           <tr>
               <td class="border">
                   <img src="<?php echo TEMPLATE_DIR; ?>/images/menu_bottom.gif" border="0" alt="" />
               </td>
           </tr>
           </table>
       
       </form>
       <?php
       } elseif (FRONTEND_LOGIN AND $wb->is_authenticated()) {
       ?>
       <form name="logout" action="<?php echo LOGOUT_URL; ?>" method="post">
           
           <table cellpadding="0" cellspacing="0" border="0" width="150" align="center" style="margin-top: 10px;">
           <tr>
               <td class="border">
                   <img src="<?php echo TEMPLATE_DIR; ?>/images/menu_top.gif" border="0" alt="" />
               </td>
           </tr>
           <tr>
               <td class="login" style="text-transform: uppercase;">
                   <b><?php echo $TEXT['LOGGED_IN']; ?></b>
               </td>
           </tr>
           <tr>
               <td class="login" style="padding-top: 15px; padding-bottom: 15px;">
                   <?php echo $TEXT['WELCOME_BACK']; ?>, <?php echo $wb->get_display_name(); ?>
               </td>
           </tr>
           <tr>
               <td class="login">
                   <input type="submit" name="submit" value="<?php
                       echo $MENU['LOGOUT']; ?>" style="margin-top: 3px; text-transform: uppercase;" />
               </td>
           </tr>
           <tr>
               <td class="login">
                   <a href="<?php echo PREFERENCES_URL; ?>"><?php echo $MENU['PREFERENCES']; ?></a>
               </td>
           </tr>
           <tr>
               <td class="border">
                   <img src="<?php echo TEMPLATE_DIR; ?>/images/menu_bottom.gif" border="0" alt="" />
               </td>
           </tr>
           </table>
       
       </form>
       <?php
       }
       ?>
   </td>
   <?php } ?>
   <td class="content" width="600" rowspan="2">
       <?php page_content(); ?>
   </td>
</tr>
<tr>
   <td height="20" width="155" valign="bottom" class="powered_by">
       <a href="http://www.websitebaker.org/" target="_blank">
           <img src="<?php echo TEMPLATE_DIR; ?>/images/powered.jpg" border="0" alt="Powered By WebsiteBaker" />
       </a>
   </td>
</tr>
<tr>
   <td colspan="2" class="border">
       <img src="<?php echo TEMPLATE_DIR; ?>/images/footer.png" border="0" alt="" />
   </td>
</tr>
<tr>
   <td colspan="2" class="footer">
       <?php page_footer(); ?>
   </td>
</tr>
</table>
<?php
// automatically include optional WB module file frontend_body.js)
if (function_exists('register_frontend_modfiles_body')) { register_frontend_modfiles_body(); }
?>
</body>
</html>
[url="http://www.jsnit.com/"]http://www.jsnit.com/[/url]

erpe0812

QuoteWhere do I add another show_menu() inside the index.php file
Exactly there where you want the flags located.

rgds

erpe

jsn

Hi all,

I am reading:
http://help.websitebaker.org/pages/en/advanced-docu/designer-guide/multilingual-websites.php?searchresult=1&sstring=multilingual

Step 3: "Required template modifications", Section "Allow language change from any displayed page".

"To add a text link with the menu titles (EN, DE) of the container pages, add another show_menu() ". Where do I add another show_menu() inside the index.php file. Is there any example?

I am using Round template and wb_theme.

IS there somewhere an explanation in how http://start.websitebaker2.org/en/introduction.php  added the three languages on the header DE, EN, NL.  This is exactly want I want to do with only two languages.

Thanks

[url="http://www.jsnit.com/"]http://www.jsnit.com/[/url]