[opencms-dev] Sharing content in multisite installation

Michael Moossen m.moossen at alkacon.com
Wed Feb 3 12:00:43 CET 2010


Dear all!

 > * use the method CmsObject.setSiteRoot you to switch to a different
 > site
 > root temporarily and then switch back after reading what you wanted to
 > read. You have to be *very* careful with that...

Just clone the cms context using this method:
OpenCms.initCmsObject(cms)

but, any way, that is most likely NOT what you want/need.

this is a tricky issue. the way to go is:
- shared files under /system/
- personalized resource initialization handler for nice URIs (no 
/system/article/0001.html)
- personalized locale handler to handle i18n for those files.

HTH
-------------------
Michael Moossen

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org

Christian Steinert schrieb:
> Lammersdorf, Lorenz wrote:
>> Hi all,
>>  
>> does anybody if this is possible?
>>  
>> I have a multisite installation of OpenCms 7.04. Let's say in /home/site1/news I've a couple of files I want to use in /home/site2 also.
>> A template containing
>>  
>> <cms:contentload collector="allInFolderDateReleasedDesc" param="/home/site1/news/|PressRelease|4">
>>  
>>
>> Is there any way to access those files without creating siblings?  
> Dear Lorenz
> 
> you can not directly read files from another site.
> 
> There are several possibilities:
> * create the files that you want to share somewhere inside of /system/
> * there is a section in one of the xml configuration files in the real 
> file system which allows to define immutable resources. Maybe this 
> works, maybe this does not work. You have to try.
> * use the method CmsObject.setSiteRoot you to switch to a different site 
> root temporarily and then switch back after reading what you wanted to 
> read. You have to be *very* careful with that, because I don't know if 
> this also works if you have several concurrent requests for the same 
> session. Also, of course you would have to do the switching in a way 
> that ensures the switch-back even if exceptions occur:
> 
>    //1.remember current site (CmsObject.getSiteRoot())
>    try{
>      //2.switch to other site root (CmsObject.setSiteRoot)
>      //3. do something
>    } finally {
>      //4. switch back to the previously active project 
> (CmsObject.setSiteRoot)
>    }
> 
> To make things clean and thread-safe, you might have to syncronize ALL 
> this kind of activity against ONE COMMON lock-object to avoid that 
> several requests from the same session damage each other's context while 
> working concurrently.
> 
> Then, this kind of switching-functionality could be wrapped into a 
> custom tag and then used inside of your templates
> 
> These are the possibilities that comes to my mind.
> 
> Best regards
> Christian
> 
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev



More information about the opencms-dev mailing list