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.

eZ debug

Timing: Jan 19 2025 04:19:44
Script start
Timing: Jan 19 2025 04:19:44
Module start 'layout'
Timing: Jan 19 2025 04:19:44
Module start 'content'
Timing: Jan 19 2025 04:19:44
Module end 'content'
Timing: Jan 19 2025 04:19:44
Script end

Main resources:

Total runtime0.0166 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 589.4141152.6563
Module start 'layout' 0.00570.0023 742.070339.5078
Module start 'content' 0.00810.0065 781.578197.5234
Module end 'content' 0.01460.0020 879.101638.3047
Script end 0.0166  917.4063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002515.0742140.0002
Check MTime0.00127.4389140.0001
Mysql Total
Database connection0.00074.087810.0007
Mysqli_queries0.001911.650030.0006
Looping result0.00000.246510.0000
Template Total0.00169.910.0016
Template load0.00095.410810.0009
Template processing0.00074.453310.0007
Override
Cache load0.00063.852810.0006
General
dbfile0.002615.756580.0003
String conversion0.00000.053040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

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

Time used to render debug report: 0.0001 secs