Forums / Setup & design / How can I manipulate strings in ezpublish template language?

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?)

eZ debug

Timing: Jan 19 2025 06:09:30
Script start
Timing: Jan 19 2025 06:09:30
Module start 'content'
Timing: Jan 19 2025 06:09:32
Module end 'content'
Timing: Jan 19 2025 06:09:32
Script end

Main resources:

Total runtime1.3384 sec
Peak memory usage4,096.0000 KB
Database Queries208

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 590.3438180.7969
Module start 'content' 0.00671.1728 771.1406633.8750
Module end 'content' 1.17950.1588 1,405.0156341.0234
Script end 1.3384  1,746.0391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.3016210.0002
Check MTime0.00150.1109210.0001
Mysql Total
Database connection0.00080.056910.0008
Mysqli_queries1.262094.28922080.0061
Looping result0.00220.16632060.0000
Template Total1.308397.720.6541
Template load0.00190.139220.0009
Template processing1.306497.607420.6532
Template load and register function0.00020.016710.0002
states
state_id_array0.00190.142110.0019
state_identifier_array0.00140.101520.0007
Override
Cache load0.00160.1215490.0000
Sytem overhead
Fetch class attribute can translate value0.00120.091840.0003
Fetch class attribute name0.00100.076880.0001
XML
Image XML parsing0.00100.072940.0002
class_abstraction
Instantiating content class attribute0.00000.001080.0000
General
dbfile0.00360.2683290.0001
String conversion0.00000.000530.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
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 36
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs