[opencms-dev] finding the sibling with specified locale

Christoph P. Kukulies kuku at physik.rwth-aachen.de
Tue Mar 15 17:29:05 CET 2011


Found a solution in some old code of mine which I might have
grabbed from elsewhere:

String currentUri = cms.getRequestContext().getUri();
String altUri="FOO";
CmsRequestContext rec=cms.getRequestContext();

String strPagename = cms.getRequestContext().getUri();
   // out.write("cms.getRequestContext:"+strPagename+"<br><hr><br>");
   List siblings = o.readSiblings(strPagename, CmsResourceFilter.ALL);
      for (int i = 0, l = siblings.size(); i < l; i++) {
                String vfsName =
                   rec.removeSiteRoot(((CmsResource)siblings.get(i)).getRootPath());
             // out.write("vfsName:"+ vfsName + "<br>");
                if(!vfsName.equals(currentUri))
                      altUri=vfsName;
        }

Sth. in this vein does the job.


--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
On Mon, Mar 14, 2011 at 06:46:13PM +0100, Christoph P. Kukulies wrote:
> How can I find out the complete uri of the sibling of a resource that carries
> he specified locale?
> 
> E.g. In the VFS I have
> 
> /de/Impressum/index.htm
> /en/Imprint/index.htm
> 
> de is a directory
> en is a directory
> Imprint is a sibling of Impressum (having resp. locale each)
> index.htm are siblings. (having locale en resp. de)
> 
> When I have opened /de/Impressum/index.htm in the page I would like to
> switch to the en-locale page by finding the sibling with full
> en path name ?
> 
> 
> --
> Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de



More information about the opencms-dev mailing list