multi lingual url: how to make a link between two versions ?

Author Message

Xavier Dutoit

Monday 12 November 2007 8:49:12 am

Hi,

With the new feature allowing multi language urls:
http://ez.no/doc/ez_publish/technical_manual/3_10/features/multi_language_support_for_url_aliases

The previous code examples to make link between two linguistic versions doesn't work (well)

When I'm reading example.com/en/company/about_us I wan't to display a french flag with a link to example.com/fr/companie/a_propos

Any example of how to do that ? I didn't remember having seen something.

Any suggestion more than welcome.

X+

http://www.sydesy.com

Stéphane Bullier

Tuesday 13 November 2007 1:09:56 am

Hello Xavier,

I use the template "Template look" and add matrix "Language settings" with 3 colums : Site URL, Siteaccess, Language name.

I fetch the template look :

{def $pagedesign = fetch( 'content', 'object', hash( 'object_id', '54' ) ) }

<ul id="languages">
{foreach $pagedesign.data_map.language_settings.content.rows.sequential as $row}
{def $site_url = $row.columns[0]
	 $site_access = $row.columns[1]
	 $language = $row.columns[2]}
{if $row.columns[0]}
	{set $site_url = $site_url|append( "/" )}
{/if}
{if $row.columns[1]}
	{set $site_access = $site_access|append( "/" )}
{/if}

{if $row.columns[0]}
	<li>
	{if is_set($DesignKeys:used.url_alias)}
		{if $row.columns[1]|downcase()|eq($access_type.name)}
		<span>{$language}</span>
		{else}
		<a href="{concat( "http://", $site_url, $DesignKeys:used.url_alias )}">{$language}</a>
		{/if}
	{else}
		<a href="{concat( "http://", $site_url, $uri_string )}">{$language}</a>
	{/if}
	</li>
{/if}
{undef $site_url $site_access $language}
{/foreach}
</ul>

Stéphane

Xavier Dutoit

Tuesday 20 November 2007 1:11:03 am

Hi,

Does it work in 3.10 ? With the multi-lingual url feature activated ?

I have to admit that I didn't test the code you shared with us, but it doesn't look like the

/en/This-address can be transformed into /fr/Cette-adresse

Or am I missing something ?

X+

http://www.sydesy.com

Xavier Dutoit

Tuesday 20 November 2007 1:28:20 am

See a related discussion there:
http://ez.no/developer/forum/developer/multi_lingual_url_how_to_make_a_link_between_two_versions

http://www.sydesy.com

Stéphane Bullier

Wednesday 21 November 2007 2:00:18 am

Hello,

Sorry my script was for 3.9 version.

I try to install an 3.10 version with ezwebin_site extension. And the script for switch between language is :

<div id="languages">
        {if $locales|count|gt( 1 )}
        <ul>
        {foreach $pagedesign.data_map.language_settings.content.rows.sequential as $row}
        {def $site_url = $row.columns[0]
             $language = $row.columns[2]}
        {if $row.columns[0]}
            {set $site_url = $site_url|append( "/" )}
            <li{if $row.columns[1]|downcase()|eq($access_type.name)} class="current_siteaccess"{/if}>
            {if is_set($DesignKeys:used.url_alias)}
                <a href="{concat( "http://", $site_url,
                         $DesignKeys:used.url_alias
                         )}">{$language}</a>
            {else}
                <a href="{concat( "http://", $site_url,
                         $uri_string
                         )}">{$language}</a>
            {/if}
            </li>
        {/if}
        {undef $site_url $language}
        {/foreach}
        </ul>
        {/if}
    </div>

This code work for MatchOrder=uri

Stéphane

Xavier Dutoit

Wednesday 21 November 2007 3:03:38 am

Hi,

Thanks for sharing.
Are you using it with the new url format ?

Still got an issue, and I can't get both

/en/Company/About-Us
and it's translated url
/fr/Companie/A-Propos

Does it work for you or did you keep the "old" url format (I wish I had)?

X+

http://www.sydesy.com

Stéphane Bullier

Thursday 22 November 2007 5:33:36 am

Hello,

I use the new format with default parameters. I don't override transform.ini

fre/Companie/A-propos
eng/Company/About-company

But when you switch to fre/Companie/A-propos from eng you have : eng/Companie/A-propos

The url is not refreshed.

Stéphane

Xavier Dutoit

Friday 23 November 2007 1:07:00 am

Ok,

I have the same result, with the same page having various urls.

Am I the only one thinking that's really really bad SEO practice ?

X+

http://www.sydesy.com

Tobias Vogel

Tuesday 27 November 2007 8:23:38 am

I made a custom operator, to fetch the url-alias of a node in a specific language by node-id.

Example usage:

<a href={fetch_url_alias($node.node_id, 'ger-DE')|ezurl()}>Read it in german</a>
<a href={fetch_url_alias($node.node_id, 'eng-US')|ezurl()}>Read it in english</a>

The operator is avilable via an extension, see the following link for details more and downloading:
http://ez.no/developer/contribs/hacks/fetch_multilingual_url_alias_by_locale

Hope this helps and kind regards,
Tobias

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 18:31:54
Script start
Timing: Jan 18 2025 18:31:54
Module start 'layout'
Timing: Jan 18 2025 18:31:54
Module start 'content'
Timing: Jan 18 2025 18:31:54
Module end 'content'
Timing: Jan 18 2025 18:31:54
Script end

Main resources:

Total runtime0.8531 sec
Peak memory usage4,096.0000 KB
Database Queries77

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0058 588.1719152.6563
Module start 'layout' 0.00580.0027 740.828139.5078
Module start 'content' 0.00850.8433 780.3359657.0000
Module end 'content' 0.85170.0013 1,437.335924.0938
Script end 0.8531  1,461.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.4347160.0002
Check MTime0.00140.1690160.0001
Mysql Total
Database connection0.00080.090910.0008
Mysqli_queries0.770290.2799770.0100
Looping result0.00070.0828750.0000
Template Total0.820596.220.4102
Template load0.00250.289320.0012
Template processing0.818095.882820.4090
Template load and register function0.00010.013010.0001
states
state_id_array0.00110.134510.0011
state_identifier_array0.00110.129320.0006
Override
Cache load0.00230.2716700.0000
Sytem overhead
Fetch class attribute can translate value0.00110.124630.0004
Fetch class attribute name0.00200.2291110.0002
XML
Image XML parsing0.00110.134630.0004
class_abstraction
Instantiating content class attribute0.00000.0051170.0000
General
dbfile0.00080.0978220.0000
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
16content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 45
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs