WebsiteBaker Community Forum

General Community => Global WebsiteBaker 2.8.x discussion => Topic started by: jsn on October 20, 2009, 03:20:14 AM

Title: How to "Allow language change from any displayed page"?
Post by: jsn on October 20, 2009, 03:20:14 AM
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

Title: Re: How to "Allow language change from any displayed page"?
Post by: erpe0812 on October 20, 2009, 10:25:04 AM
Quote
Where do I add another show_menu() inside the index.php file
Exactly there where you want the flags located.

rgds

erpe
Title: Re: How to "Allow language change from any displayed page"?
Post by: jsn on October 20, 2009, 04:47:11 PM
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_m odfiles')) {
        register_frontend_m odfiles('css');
        register_frontend_m odfiles('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_m odfiles_body')) { register_frontend_m odfiles_body(); }
?>
</body>
</html>
Title: Re: How to "Allow language change from any displayed page"?
Post by: erpe0812 on October 20, 2009, 04:55:51 PM
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
Title: Re: How to "Allow language change from any displayed page"?
Post by: doc on October 20, 2009, 05:32:53 PM
Hi,

there are solutions posted in the forum of how to switch languages. Some links are:
https://forum.WebsiteBaker.org/index.php/topic,14015.msg91756.html#msg91756
https://forum.WebsiteBaker.org/index.php/topic,14037.0.html
http://wbdemo.heysoft.de/pages/en/easymultilanguagelink.php?lang=EN

Regards Doc
Title: Re: How to "Allow language change from any displayed page"?
Post by: jsn on October 20, 2009, 05:36:29 PM
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

Title: Re: How to "Allow language change from any displayed page"?
Post by: jsn on October 20, 2009, 05:41:51 PM
Thanks Doc I appreciate your help!
Title: Re: How to "Allow language change from any displayed page"?
Post by: erpe0812 on October 20, 2009, 05:48:28 PM
Quote
If 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

Title: Re: How to "Allow language change from any displayed page"?
Post by: jsn on October 20, 2009, 05:59:07 PM
I did it! And I am doing it! For example after intalling the Add On to manage tempaltes things became more clear!
Title: Re: How to "Allow language change from any displayed page"?
Post by: doc on October 20, 2009, 06:05:15 PM
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:
Code: [Select]
<?php
    $flags_path 
WB_PATH.MEDIA_DIRECTORY.&#39;/flags&#39;;
    
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) != &#39;.&#39; AND $file != &#39;index.php&#39;) {
                    
$pathinfo pathinfo($file);
                    
$language strtolower(str_replace(&#39;.&#39;.$pathinfo[&#39;extension&#39;],&#39;&#39;,$file));
                    
?>

                    <td>
                        <a href="<?php echo WB_URL.&#39;/pages/&#39;.$language.PAGE_EXTENSION; ?>">
                            <img src="<?php echo WB_URL.MEDIA_DIRECTORY.&#39;/flags/&#39;.$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:

Code: [Select]
<?php
show_menu
(101true"[a]<img src=" .WB_URL ."/media/flags/[menu_title].gif />[/a]", &#39;&#39;, &#39;&#39;, &#39;&#39;, false, &#39;&#39;, 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
Title: Re: How to "Allow language change from any displayed page"?
Post by: jsn on October 20, 2009, 06:21:10 PM
Thank you

I also found this link in goolge very usefull:

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

Title: Re: How to "Allow language change from any displayed page"?
Post by: jsn on October 21, 2009, 12:09:22 PM
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


Title: Re: How to "Allow language change from any displayed page"?
Post by: doc on October 21, 2009, 12:25:45 PM
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: jsn
But, 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
Title: Re: How to "Allow language change from any displayed page"?
Post by: jsn on October 21, 2009, 02:43:22 PM
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.


Title: Re: How to "Allow language change from any displayed page"?
Post by: LordDarkman on October 21, 2009, 05:19:31 PM
Quote
To 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
Title: Re: How to "Allow language change from any displayed page"?
Post by: doc on October 21, 2009, 06:39:40 PM
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:
Code: [Select]
<?php
show_menu
(
  
$menu_number 1,
  
$start_level 0,
  
$recurse 1,
  
$collapse =  true,
  
$item_template = &#39;[a]<img src=&#39; . WB_URL . MEDIA_DIRECTORY . &#39;/flags/[menu_title].gif />[/a]&#39;,
  
$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 (http://help.WebsiteBaker.org/pages/en/advanced-docu/designer-guide/multilingual-websites.php#anker1) (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
Title: Re: How to "Allow language change from any displayed page"?
Post by: LordDarkman on October 21, 2009, 06:49:45 PM
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
Title: Re: How to "Allow language change from any displayed page"?
Post by: jsn on October 22, 2009, 01:03:16 AM
Thanks, reading the Page Source of this web site I was able to understand everything