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

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

eZ debug

Timing: Jan 18 2025 15:16:10
Script start
Timing: Jan 18 2025 15:16:10
Module start 'content'
Timing: Jan 18 2025 15:16:10
Module end 'content'
Timing: Jan 18 2025 15:16:10
Script end

Main resources:

Total runtime0.2200 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 587.9688180.7969
Module start 'content' 0.00740.0060 768.7656106.1016
Module end 'content' 0.01340.2065 874.8672534.6719
Script end 0.2199  1,409.5391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00431.9350200.0002
Check MTime0.00150.6692200.0001
Mysql Total
Database connection0.00100.431910.0010
Mysqli_queries0.168776.69721410.0012
Looping result0.00140.65171390.0000
Template Total0.206293.710.2062
Template load0.00100.444110.0010
Template processing0.205293.265110.2052
Override
Cache load0.00070.324510.0007
Sytem overhead
Fetch class attribute can translate value0.00100.457710.0010
XML
Image XML parsing0.00030.155110.0003
General
dbfile0.00532.4016200.0003
String conversion0.00000.002730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs