How can I manipulate strings in ezpublish template language?

Author Message

Ulrich L.

Friday 26 November 2004 1:18:48 pm

Hi,
I intend to make the language selection in my multilingual site work like this: change the language, but don't change the displayed page. For this purpose, I'd like to get the current URL and replace the current siteaccess with the new chosen one (for example: ezpath/de/view... instead of ezpath/en/view...). How can I achieve this, how can I manipulate the URL string with the functions of the template language? Or is there another way?

Ole Morten Halvorsen

Friday 26 November 2004 1:57:22 pm

Hi,

Is this what you are trying to achieve?

<a href="{concat('/se/', $DesignKeys:used.url_alias)}">Swedish</a>
<a href="{concat('/de/', $DesignKeys:used.url_alias)}">German</a>

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

Ulrich L.

Saturday 27 November 2004 5:21:56 am

Thanks for your post. Your suggestion produced on my site:
www.mydomain.com/de/path_to_page

This does not work on my server.
What I need is:
www.mydomain.com/path_ez_root/index.php/de/path_to_page

However, your suggestion comes very close to the solution!

Ulrich L.

Saturday 27 November 2004 6:25:19 am

O.k., I found a solution:
<a href={concat('/path_to_ezroot/index.php','/de/',DesignKeys:used.url_alias)}>

I didn't manage not to hardcode the first part of the path. ezroot-operator doesn't work together with concat, because it treats the quote marks differently. Does anybody have an idea how to realize this?

Anyway, thanks a lot, Ole Morten, for your Friday night input.

Ɓukasz Serwatka

Saturday 27 November 2004 9:27:20 am

Hi

Try this

<a href="{concat('/se/', $DesignKeys:used.url_alias)|ezurl}">Swedish</a>
<a href="{concat('/de/', $DesignKeys:used.url_alias)|ezurl}">German</a>

I hope this work

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Ulrich L.

Saturday 27 November 2004 2:46:33 pm

Thanks Luke, but this results in a wrong URL (e.g.
ez_path/index.php/en/de/path_to_page
instead
ez_path/index.php/de/path_to_page)

The following works fine:

<a href={concat('/index.php','/de/', $DesignKeys:used.url_alias)|ezroot}>German</a>

Ulrich L.

Monday 29 November 2004 2:32:11 am

I found out:
Using the construction

<a href={concat('/index.php','/de/', $DesignKeys:used.url_alias)|ezroot}>German</a>

works fine in general, but doesn't take care of the offset in list views with several pages: For example: Viewing the second page of a list corresponds with URL
ezpath/index.php/de/products/(offset)/10

When changing the language here, the new view will result in an URL
ezpath/index.php/en/products,
that means, the offset is lost.

Manipulating the string like this
ezpath/index.php/en/products/(offset)/10
gives the desired view back.
So how can I manipulate the string in the template? Is it a good idea to use PHP here, or are there any other suggestions? (And how to integrate PHP best?)

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