WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: FrankH on June 02, 2009, 07:56:48 PM

Title: Snippet: Easy Multilanguage Link
Post by: FrankH on June 02, 2009, 07:56:48 PM
The WB Code snippet Easy Multilanguage Link is useful on multilanguage sites only. It provides links to pages in other languages with the same content as the current page.
It is not necessary that all pages exist in all languages or that the page trees of different languages have the same structure.

How it works:

It is necessary to replace some kernel files, because we need a new field (I called it Page Code) in the page settings. For all pages with the same content you enter the same Page Code (you can also call it keyword).

The snippet will show the languages of all pages with the same Page Code as link menue.

There are two special Page Codes:

    * home is the home page of a language. It is used when no page with the current page code is available for a language.
    * none does switch off the language menu for the current page. This might be useful within a multipage form, for instance.

Add the following line to your template:

Code: [Select]
<?php easymultilang_menu(); ?>
The file HowTo.txt explains the necessary steps.

Home page of the snippet on AMASP: http://www.websitebakers.com/pages/code-snippets/various/easy-multilanguage-link.php (http://www.websitebakers.com/pages/code-snippets/various/easy-multilanguage-link.php)
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on July 03, 2009, 02:52:16 AM
I dont want to double the post..

http://www.websitebaker2.org/forum/index.php/topic,14312.msg89357.html#msg89357

Great job man !!!

Cheers
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on July 15, 2009, 06:50:59 PM
Hi,

I found the bug when you use search, the menu dissapears.. ??? Did you find the solution for this ?

You can see the example: http://wbdemo.heysoft.de/pages/en/multilingual-sites.php

cheers

Title: Re: Snippet: Easy Multilanguage Link
Post by: FrankH on July 15, 2009, 08:04:18 PM
Hi,

I found the bug when you use search, the menu dissapears.. ??? Did you find the solution for this ?

You can see the example: http://wbdemo.heysoft.de/pages/en/multilingual-sites.php

cheers



This has nothing to do with the snippet.
It is because my menu (sm2) does not show the root level.
If you are on a german language page, it does show all what is beneath http://wbdemo.heysoft.de/pages/de/
If you are on a english language page, it does show all what is beneath http://wbdemo.heysoft.de/pages/en/
If you are on the search page, it does show all what is beneath http://wbdemo.heysoft.de/search/
Because there are no subpages in the last case, the menu correctly does show nothing.
So if I would want to show the menu always, I would need to include the root level, that's all.

Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on July 15, 2009, 09:34:49 PM
Please check this link, I put MY in search box:

Code: [Select]
http://wbdemo.heysoft.de/search/index.php?string=my&submit.x=0&submit.y=0&submit=Search&search_path=/en

The menu on the left is not visible..

I kinda fixed this problem by putting both languages in root, and it is working, so there is no need to put english pages in /en and germans in /de   as language flags can separate them..

Now I have other problem, when I search something on my test site, I lose FLAGS, and I get {l_loop} text

I removed text next to flags, like you have FLAG English, Flag German.

.htt file looks like this:

Code: [Select]
<!-- BEGIN l_block -->
<span class="{CLASS}">
        {ASTART}<img src="{IMG}" /> {AEND}
</span>
<!-- END l_block -->

Can you guide me how to keep the flags dissapearing :)
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on July 15, 2009, 09:41:08 PM
did you modified anything more in the search page or something ?
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on July 16, 2009, 05:51:26 PM
I tried to include this into search/index.php page but no luck, the language are still gone...

Code: [Select]
include_once(WB_PATH."/modules/easymultilang/include.php");


Maybe someone else can help, How to include function easymultilang_menu()    from file /modules/easymultilang/include.php    into /search/index.php page ?
Title: Re: Snippet: Easy Multilanguage Link
Post by: FrankH on July 16, 2009, 08:08:03 PM
Please check this link, I put MY in search box:

Code: [Select]
http://wbdemo.heysoft.de/search/index.php?string=my&submit.x=0&submit.y=0&submit=Search&search_path=/en

The menu on the left is not visible..

This is correct, and in my last post I explained why it is. This is not a bug, but a feature :-)
But I just found something strange you did not mention:
When I call search on the page, the language menu is still available.
But when I follow an external link to the search page, the language menu is not available.
Despite there is no much sense in a link to a search page, it is really strange. I will check this as soon as I find some time.

Quote
Can you guide me how to keep the flags dissapearing

???

Quote
did you modified anything more in the search page or something ?

No, why should I?
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on July 16, 2009, 08:38:24 PM
In case I didnt explain it well, on the search result page:  /search/index.php  the flags dissapeared.. and there is no html code for them when I view source..

Also, sometimes I get:   {l_loop}   text, which is also in the source..

So basicly the question now is, how to link this {l_loop}  from module and search page :)

cheers
Title: Re: Snippet: Easy Multilanguage Link
Post by: FrankH on July 17, 2009, 11:45:34 AM

Also, sometimes I get:   {l_loop}   text, which is also in the source..


Is this reproducable? How?
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on July 17, 2009, 03:18:10 PM
I found it, i had nowhere "home" --as  PAGE CODE set , and now flags are visible now :))


Also I noticed even on your page, the language is allways selected EXCEPT on the search page, where current language is not "selected" (on your page marked with yellow background)

Can it be marked on search page too ? I tried to change your php code but had no luck :)


Also, I think that this module should me integrated into WB 2.8..

Here is EXAMPLE:

CASE 1 , OLD Multilanguage way:
Code: [Select]
EN
- Page 1
- Page 2
-- Sub page 1
DE
- Page 1
- Page 2
-- Subpage 1

CASE 2, With this module:
Code: [Select]
Home                          --- EN. language
Galery                          --- EN language
- Video galery                --- EN language
GermanHome                --- DE language
GermanGalery                --- DE language
- German Video Galery     -- DE language

good things I found are:

I noticed that you can place pages with different languages in ROOT, and only the pages of selected languages will be displayed. (if Defult language is EN, pages in root and root+1,2,3.. levels in DE language will not be displayed )

That means that you do not have to make separate /en and /de...  folders for different languages, which would be the root menu ( like in CASE 1) as most people did before. So you will not loose menu when you search -- which was bug , as your root will be displayed after search. (the bug was when you searched, on search page, only root meny was displayed and because your root menu was flags to change the language - CASE 1, menubar was empty)


And what is most important, by clicking on flags, you will be redirected to exact page on different language, and not on the root of /en or /de if you had page structure like in CASE 1..


Guys, please reconsider this :))

cheers

Title: Re: Snippet: Easy Multilanguage Link
Post by: FrankH on July 17, 2009, 05:38:27 PM
Also I noticed even on your page, the language is allways selected EXCEPT on the search page, where current language is not "selected" (on your page marked with yellow background)

Can it be marked on search page too ? I tried to change your php code but had no luck :)

I just relaesed version 0.3.0 which does not have the problem with the search page anymore :-)
A search page does not have a language, this is why no language is marked as current.
This way you can jump to the start pages of any language from search.

Quote
Also, I think that this module should me integrated into WB 2.8..

Say this to the developers...
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on July 18, 2009, 02:39:13 AM
Nice, just tested it and now it automaticly updates the database :)) great  :-D :-D


I tested it with WB 2.8 RC1 , its working great :)

Just to mention, that "home" page code should be defined, in order to avoid  {l_loop} text whch happened to me :))

Developers, it would be nice to include this to 2.8

Once again Frank, great job.. I really like this :)
Title: Re: Snippet: Easy Multilanguage Link
Post by: BerndJM on July 18, 2009, 03:49:47 AM
@crnogorac081:

Quote
Developers, it would be nice to include this to 2.8
nope ... 2.8 is RC1 where RC1 means "feature freeze only bug fixing".
But nevertheless feel free to open a feature request for 2.9
http://project.websitebaker2.org/newticket

Regards Bernd
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on July 18, 2009, 01:25:05 PM
ok, Im just sayin this is better way to create multilanguage sites :))

Anyway, I'll post the ticket :)
Title: Snippet: Easy Multilanguage Link v 0.4
Post by: FrankH on July 18, 2009, 02:38:45 PM
For all those who do not want to wait for WB 2.9 to come with better multilanguage support:
I just released version 0.4 of the snippet.
It comes with patched files for WB 2.8 and a help file explaining how to patch (it is just as easy as moving some files).
After you installed the module:

For security reasons, do not forget to delete both patch directories after you patched the installation!
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on July 18, 2009, 03:29:53 PM
Hi FrankH,

what is the difference between 0.3.0 and 0.4.0 ?
Title: Re: Snippet: Easy Multilanguage Link
Post by: FrankH on July 18, 2009, 03:33:21 PM
what is the difference between 0.3.0 and 0.4.0 ?

Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on July 19, 2009, 11:51:41 PM
nice nice, I really like this module.

Also on thi thread: http://www.websitebaker2.org/forum/index.php/topic,14555.0.html  you can find how to adapt your search funcion.

cheers

Title: Re: Snippet: Easy Multilanguage Link
Post by: mava100 on September 08, 2009, 04:46:34 PM
due to my poor skill on php, html, ecc.
where i can put "<?php easymultilang_menu(); ?>"?

in index.php
in *.css?

thanks
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on September 08, 2009, 05:23:16 PM
in <div><?php easymultilang_menu(); ?> </div> of index.php file where you want multilanguage menu to appear..

cheers
Title: Re: Snippet: Easy Multilanguage Link
Post by: mava100 on September 08, 2009, 05:34:44 PM
thanks!
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on November 09, 2009, 07:01:18 PM
Hi Frank,

Is there a way to define order of flags ?

For example in my menu tree I have me, en, ru languages

In snippet flag order is en, me , ru ... And If I change defult frontend language in settings, it doesnt change the order.... I would like to set me flag first..

is it possible ?

cheers
Title: Re: Snippet: Easy Multilanguage Link
Post by: FrankH on November 09, 2009, 07:33:38 PM
Hi Ivan,

you would need to make some code changes.
But would it be a good idea?
Usually users expect the same link to stay on the same position. It would annoy most people when they have to start searching a link after it changed its position, I think.
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on November 09, 2009, 08:53:07 PM
Hi Frank,

Please see the image attached. I noticed I ask few questions in same sentence :) So I'll split them:

1. I have menu tree like this:
ME
- ME page 1
- ME page 2
- ...
EN
- EN page 1
- EN page 2
- ..
RU
- RU page 1
- RU page 2
- ...

I understand that it is a little non usual, but is it possible, if you would do any further development for this module, that flags (like on my screenshoot ) use order from menu tree ?

2. My defult language in backend is set to ME, so I would like first flag to be ME, and not EN (like on my screenshoot ) , is it possible ? Does the snippet use alphabet order to set order for flags ?

all best,
I.

[gelöscht durch Administrator]
Title: Re: Snippet: Easy Multilanguage Link
Post by: renjithtk07 on November 10, 2009, 10:00:00 AM
Hi,

I am trying to add the multilanguage to my site. I have installed the multilanguage module. I have added the code to display the multilanguage icons to the index.php page.

My site have 4 pages in english. Now do I need to create another four pages for spanish? I am not getting a clear idea about how I need to set it. Could you please provide a basic documentation by which a user who is not so much familiar with website baker and multilanguage can get a better idea to use it.

Thanking you..
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on November 10, 2009, 03:32:52 PM
Hi,

First - Just dont forget to install the patch files..

No, as it is mentioned in first post, you do not need to have same pages on different languages.

For example:

EN                                ES
Home    <home>           Home es
Page 1    <page1>         Pagina 1
Page 2     <seccond>     Paggina 2
Page 3

In <> is page code which needs to be inpuded in page settings. In this example, you see that Page 3 has no match page on spanish. When you click on flag image while you are on that page, you will be redirected to page where you set "home" page code.

Cheers

Title: Re: Snippet: Easy Multilanguage Link
Post by: FrankH on November 10, 2009, 05:31:58 PM

I understand that it is a little non usual, but is it possible, if you would do any further development for this module, that flags (like on my screenshoot ) use order from menu tree ?

2. My defult language in backend is set to ME, so I would like first flag to be ME, and not EN (like on my screenshoot ) , is it possible ? Does the snippet use alphabet order to set order for flags ?


Hi Ivan,

Sure it is possible, but needs some work, I assume. Currently I am finnishing the mpform help project with 40 pages of documentation, afterwards there is already another large task, so I won't have time during the next months for this snippet.

Regarding the last question: I think currently we have an unsorted list, but better look into the source code.
Title: Re: Snippet: Easy Multilanguage Link
Post by: babsy on February 10, 2010, 10:59:37 AM
sorry, but where do you mean that we should copy the files to:

from /modules/easymultilang/patch2.8.0
to the directory with the same name under your WB path ??

i don´t know where you mean, when you say:
to the directory with the same name under your WB path ??
 ?

i have installed it, and now all the pages show up, both english and swedish? but i gues thats because im not finished with this moving/deleting files! :)
Title: Re: Snippet: Easy Multilanguage Link
Post by: FrankH on November 16, 2010, 05:03:59 PM
Before writing, you should have took a look into the directory /modules/easymultilang/patch2.8.0
May be this directory contains subdirectories with names, which are already there under your WB installation?
So what is your problem?
Title: Re: Snippet: Easy Multilanguage Link
Post by: pivey on December 16, 2010, 10:00:22 AM
Nice module.. thx

Have installed it as instructed, (tested with 2 languages EN + DE)
Now.. Only English flag shows up with text "English", not clickable at all.

Any thoughts?

Note: I have made the structure of the website with default multilanguage functionality of WB

Version 2.8.1
Revision 1287
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on December 17, 2010, 12:45:46 AM
Maybe all your pages are on english, check page language on page settings. Also check fill in page code , for example:

startsite => fill in "home"
start      => also fill in "home"

if it doesnt work, you can  send me a link to your site so I can take a look

Title: Re: Snippet: Easy Multilanguage Link
Post by: snark on December 18, 2010, 12:08:52 AM
Is it possible to make this menu do clever things like showmenu2 can, i mean fi:

- start at x steps down the root
- only show up till x levels
- automaticallcy add à character to THE menu title.   ( > [MENU_TITLE] )

Etc
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on December 18, 2010, 01:16:08 AM
This snippet doesnt to that. It can only transfer you to the page you select with another language.

I am not sure what are you trying to do. Can you describe on an example ?
Title: Re: Snippet: Easy Multilanguage Link
Post by: pivey on December 20, 2010, 12:06:22 PM
thx crnogorac081,

of course.. i had all pages in English language. It works fine now.
Thx again.
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on December 20, 2010, 01:17:31 PM
thx crnogorac081,

of course.. i had all pages in English language. It works fine now.
Thx again.

Note that you can set page code = home    for default page when no page on different language is selected via page code.
Title: Re: Snippet: Easy Multilanguage Link
Post by: pivey on December 22, 2010, 07:57:24 AM
Yes, did define "home" as default page to show up when no similar page exists.
So i have to asign each page with a unique "Page Code" , same in each language. Right?

That's what i did... and works like a charm.

By the way: what is the languages definition in admin good for by default? Does it handle the encoding?
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on December 22, 2010, 11:00:24 AM
not sure, never tested that, so I use standard letters :)
Title: Re: Snippet: Easy Multilanguage Link
Post by: pivey on July 01, 2011, 11:30:16 AM
Has anyone manage to change the code of flags order? It would be helpful to order according to backend language tree instead of alphabetical order, like it is now.
Title: Re: Snippet: Easy Multilanguage Link
Post by: aesteves on July 11, 2011, 04:02:41 PM
For anybody with this problem (ordering the language menu - flags, text, whatever you chose), I've solved it by, in the file "modules/easymultilang/include.php", replacing the line that orders the languages

Code: [Select]
ksort($langarr);
with this one (for my case):

Code: [Select]
$langarr = array('PT'=>$langarr['PT'], 'EN'=>$langarr['EN'], 'ES'=>$langarr['ES'], 'FR'=>$langarr['FR']);
you can change it with different languages or different order.

cheers
Title: Re: Snippet: Easy Multilanguage Link
Post by: pivey on July 13, 2011, 05:14:48 PM
@aesteves
  thx for the hint!
Title: Re: Snippet: Easy Multilanguage Link
Post by: xia on January 26, 2012, 06:02:03 PM
I Have a menu:
EN               ES
Home           Home es
Page 1          Pagina 1
Page 2          Paggina 2
Page 3
When I click to ES, open Page2 not home
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on January 27, 2012, 09:22:30 AM
Hi,

go to Pages -> Settings for ES and set page code same as for Page2

cheers
Title: Re: Snippet: Easy Multilanguage Link
Post by: xia on January 27, 2012, 12:31:34 PM
Thanks!
I don't know what you want say about "set page code"
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on January 27, 2012, 02:22:06 PM
Go to ES page -> go to settings, then in the list where title, description, language etc.. is , there is a Page Code input field. Type same word on ES and Page 2 and it will work..
Title: Re: Snippet: Easy Multilanguage Link
Post by: xia on January 29, 2012, 07:52:40 PM
I don't have "Page Code"

[gelöscht durch Administrator]
Title: Re: Snippet: Easy Multilanguage Link
Post by: Luisehahne on January 30, 2012, 06:22:59 AM
try this snippet. This snippet is the same that runs on WebsiteBaker homepage. I hope somebody helps me to write a tutorial in German and English.

Call in Template is

Code: [Select]
<?php if(function_exists('language_menu')){ language_menu('png'); } ?>
Dietmar

[gelöscht durch Administrator]
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on January 30, 2012, 09:27:21 AM
Hi,

if you see Snippets' page at AMASP: http://www.websitebakers.com/pages/code-snippets/various/easy-multilanguage-link.php

You have marked red: Requires:    Requires patch in some kernel files for additional column page_code in the pages table, see HowTo.txt

There are some files (from the patch2.8.0 folder in zipped snippet) which needs to be replaced with core files..

cheers
Title: Re: Snippet: Easy Multilanguage Link
Post by: Luisehahne on January 30, 2012, 12:00:42 PM
Quote
Requires patch in some kernel files for additional column page_code in the pages table,

And all is gone by next Release.

Dietmar
Title: Re: Snippet: Easy Multilanguage Link
Post by: freeSbee on March 08, 2014, 03:12:19 PM
Hi

I have used the WebsiteBaker Multilingual Switcher 1.6.5 and it works perfect.
http://www.WebsiteBaker.org/forum/index.php/topic,14037.msg157022.html#msg157022

I have made the language assignment manually. But the snippet also provides  a link called "Pagecode" (only existing if the snippet has been installed).
Goto: Pages > Page settings > Link "Pagecode"

After klicking the link, the previously done assignment is gone. I do not think this is the originally intended functionality. Does anybody know what this link is intended to do?

Thanks and regards
Christoph
Title: Re: Snippet: Easy Multilanguage Link
Post by: jacobi22 on March 08, 2014, 03:56:13 PM
I have used the WebsiteBaker Multilingual Switcher 1.6.5
Quote
After klicking the link, the previously done assignment is gone. I do not think this is the originally intended functionality. Does anybody know what this link is intended to do?

if you install the module on a working system (maybe with 20 pages), the install progress update the new database field "page-code" with the page-ID from every page
But if you add a new page, the system set a 0 (zero) to this database field, you have to go to the page settings and select a target page from the main language tree

when you start a project with a installed multi lingual module from the begin and add all your pages, every page has the page code "0", but the script doenst work with a target page-id == 0, it needs the real page-id from the target page or the page-ID from this page self

The Link "page-code" set all this page-code's from zero to the page-id from every page, so that multi lingual can work without problems
but.... its also a RESET - all previously settings are gone without warning!

its helpfull, if you need a fast solution for a bigger system with many pages and sometime the Reset is a good solution, but not everytime..

in the next module version in wb 2.8.4 this link will only set the page-code-fields with a 0 and dont touch my settings there
Title: Re: Snippet: Easy Multilanguage Link
Post by: crnogorac081 on March 13, 2014, 10:27:26 AM
Hi Chris,

here is what pagecode is for:
Hi,

First - Just dont forget to install the patch files..

No, as it is mentioned in first post, you do not need to have same pages on different languages.

For example:

EN                                ES
Home    <home>           Home es
Page 1    <page1>         Pagina 1
Page 2     <seccond>     Paggina 2
Page 3

In <> is page code which needs to be inpuded in page settings. In this example, you see that Page 3 has no match page on spanish. When you click on flag image while you are on that page, you will be redirected to page where you set "home" page code.

Cheers



I used  Easy Multilanguage Link Snippet, and not Multilingual Switcher so I dont know why pagecodes resets.

I had no problems with Easy Multilanguage Link Snippet, it works perfectly so far.