[opencms-dev] Site roots with third level folders // Extension to CmsSiteManagerImpl.lookupSitesFolder(String rootPath) (based on 7.5.4)
Kunicke, Holger
holger.kunicke at av-studio.de
Wed Feb 13 16:16:28 CET 2013
Hi,
because of need of site roots at third level folders like
"/sites/clientX/default/" instead of standard "/sites/default/", I has modified
CmsSiteManagerImpl.lookupSitesFolder(String rootPath) to get an correct working
<cms:link></cms:link> function.
Before my mod the "link" function produced URLs like
"http://mydomain.de/sites/clientX/default/de/index.html" because the used
lookupSitesFolder method doesn't find the siteRoot "/sites/clientX". Now the
lookupSitesFolder method look also for "/sites/clientX/default" and the produced
URLs shows like "http://mydomain.de/de/index.html" now ... Yes!
Because I'd never using CVS I post my solution here (based on OpenCMS 7.5.4).
Eventually this helps everybody or would be integrated in the current version:
private CmsSite lookupSitesFolder(String rootPath) {
int pos = rootPath.indexOf('/', SITES_FOLDER_POS);
if (pos > 0) {
// this assumes that the root path may likely start with something
like "/sites/default/"
// just cut the first 2 directories from the root path and do a
direct lookup in the internal map
CmsSite mySite = (CmsSite)m_siteRootSites.get(rootPath.substring(0,
pos));
if (mySite != null) {
return mySite;
} else {
// if no level 2 site was found, then check for site at level 3
like "/sites/clientX/default/"
int pos2 = rootPath.indexOf('/', pos + 1);
if (pos2 > pos) {
mySite = (CmsSite)m_siteRootSites.get(rootPath.substring(0,
pos2));
}
return mySite;
}
}
return null;
}
Kind regards
Holger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20130213/a5016d37/attachment.htm>
More information about the opencms-dev
mailing list