[opencms-dev] Issue with URLs when linking to different subsites

Arakelian Pierre p_arakelian at ubicast.com
Fri Jul 25 10:12:57 CEST 2014


Let's say I have two subsites, "category1" and "category2". If I try to
link to an detail page in a different category, the generated URL's
category does not change to match it.

For example, I have a page "/category1/index.html". From this page, if I
link to a detail page such as /category1/1, everything is fine. The
generated href points to category1/1. If I link to /category2/1, then the
generated href ends up pointing to /category1/1, which isn't what I want.

Is this a bug? I searched the list of issues on GitHub and didn't find
anything. I can submit an issue if this is unexpected behavior.

When I'm dealing with cms:link tags, I noticed that if I change the baseUri
to "/", the category becomes correct again. Going back to my previous
example, imagine I'm linking to pages from /category1/index.html. This is
what happens:
<cms:link>/category2/1</cms:link>  URL becomes ->  /category1/1
<cms:link baseUri="/">/category2/1</cms:link>  URL becomes ->  /category2/1

This seems fine as a workaround when I'm using cms:link tags directly, but
not when links are inserted through other means (for example, the WYSIWYG
editor). I have no control over the baseUri value in those cases.

The only very hacky workaround I found was doing this in the JSP file
itself:

CmsObject cms = CmsJspElFunctions.convertCmsObject(request);
String uri = cms.getRequestContext().getUri();
try {
cms.getRequestContext().setUri("/");
... display WYSIWYG content here ...

} finally {
cms.getRequestContext().setUri(uri);
}
This worked, but it seems quite dangerous. Do you have any other
suggestions? Or is this a bug that simply needs to be fixed? Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20140725/25bacd14/attachment.htm>


More information about the opencms-dev mailing list