[opencms-dev] cms:include, cms:param and __locale

Alejandro Alanis alanis at synyx.de
Thu Oct 2 14:47:40 CEST 2008


Hello mailinglist,

first poster here, so: hi everyone :)

Working with Opencms 7.0.5 (problem was reproduced on opencms 7.0.4), i
stumbled upon a problem that i assume to be a bug:

If you have a resource /sites/default/foo.xml (resourcetype "xmlpage")
with content in various languages (e.g. "en" and "de"), and you want to
use <cms:include> to include it corresponding to the locale set on the
frontend, you are supposed to use:

foo
   <cms:editable mode="true"/>
   <cms:include
      file="/sites/default/foo.xml"
      editable="true"
      element="body"
      >
      <cms:param name="__locale"><%= locale %></cms:param>
   </cms:include>
bar

The include itself works fine, aswell as the direct-edit. The problem
is, that the param is not passed/not evaluated by the content loader.
The result is, that the included content is always displayed in the
default language.

I tried also to work around this by creating siblings with the property
"locale" set in corresponding directories "en/" or "de/", but that didnt
work either, since the content included was STILL in the default
language, ignoring the param given AND the property set on the sibling.

After hours of trying the only workaround i found, was to rewrite the
cms:include-functionality in a scriptlet like follows:

foo
<%
   Map paramMap = request.getParameterMap();
   //paramMap.put("__locale", new String[] {language}); // this doesnt
work either
   cms.getRequestContext().setLocale(new Locale(language));
   cms.editable(true);
   cms.include("/sites/default/foo.xml", "body", true, paramMap);
%>
bar

This works as expected, but imho this is still a workaround and not a
solution :)

If anyone can shed some light on this it would be nice.

Regards

Alex Alanis







More information about the opencms-dev mailing list