[opencms-dev] Sharing content in multisite installation

Roman Uhlig Maxity.de roman.uhlig at maxity.de
Wed Feb 3 12:00:28 CET 2010


 
Keep in mind, that if you have a link to a detail page (the actual xml-page), you will send your users to another site, cause you can't "fake" it into the original site. We have some of these setups (cross-site xml content) and tried several approaches. We came to the conclusion that using siblings is the safest and user friendliest way to do it. Synchronizing siblings across sites is easy, so that should not be a problem too.

If you really want to have an independent cross-site repository, use a classic database approach instead. OpenCms' xml content is not very well suited for that.

Kind regards,
Roman


-----Ursprüngliche Nachricht-----
Von: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von Christian Steinert
Gesendet: Mittwoch, 3. Februar 2010 11:35
An: The OpenCms mailing list
Betreff: Re: [opencms-dev] Sharing content in multisite installation

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