Sharing Content Across Multiple Sites
I am under a time crunch to find a solution to this issue, so a fast response would be appreciated.
I am building a site in which multiple, independent instances will be created (for example, exampleSite01.com, exampleSite02.com). Each of these sites will have their own Sitefinity database. I want to share Events created on each of these sites across all the sites and display them on a calendar (RadScheduler). So exampleSite01.com would be able to display all events created on exampleSite01.com and exampleSite02.com, and vise-versa. How would I share this content across Sitefinity sites?
Thanks.
Hello Geoff,
The events module can be shared using the bellow steps:
1) Create the main website which will create the events.
2) Create secondary website which will pull events from the first one.
3) Add a connection string in the second site which points to the database of the first one (section Data -> ConnectionStrings in Advanced Settings).
4) Configure events data provider which pulls events items from the main website by adding connectionString parameter to the OpenAccessDataProvider parameter with value the name of the connection string from step 3. You can do this from Settings >> Advanced
Greetings,
Ivan Dimitrov
the Telerik team
Thank you for the quick response, Ivan.
It looks like this allows me to pull events from another Sitefinity site, but I need to also retain the ability to manage events from the local site database. Ideally, exampleSite01.com would have read and write privileges to the Events stored on exampleSite01.com and exampleSite02.com. Also, exampleSite02.com would have access to the same Events.
The application of this is that independent sites are going to exist for different regions. A nationwide site will have Events. A site for a particular city would have its own Events, but then also interact with the nationwide Events of the other site, so it would need access to the Events on both sites.
Is there a way to use a connection string to manage Events from another site using the fluent API? This would allow me to aggregate all the events from several sites and display them on a calendar, and hopefully edit/update the Events, if necessary.
Thanks.
Hello Geoff,
Thank you for getting back to us.
This is option is also available. In step 4 instead of editing the default data provider for events in the second website you will simply create a new events data provider with the same settings as the default one, just with different name and add connection string to the main events site. Also you will have to change the applicationName value for the default events provider.
Also please note that since you are going to share events you will also need to share taxonomies. This means that you will have to add a connectionString parameter to the default taxonomies provider.
Greetings,
Radoslav Georgiev
the Telerik team
Awesome. Thank you, Radoslav.
My next question is, how do I get access to these events through the fluent API?
I would expect this to return all the events in Sitefinity:
IList<Event> events = App.WorkWith().Events().Get().ToList();
Hi Geoff,
You should try setting the provider name before you call WorkWith using Prepare:
App.Prepare().SetContentProvider(
"NameOfYourProvider"
).WorkWith().Events();
Thank you. You have been a huge help.
I have one more question on this topic. Is there a way to get a listing of the available Content Providers, or more specifically Event Content Providers? This would allow me to iterate through the available content providers to gather all the events or to create an admin dialog to select from the available content providers, instead of hard coding the content provider name.
Thanks.
In addition to my last question, I am beginning to have issues using custom event fields while using multiple event data providers. I have created the same custom field for each event data provider. In my case, it was named "Price" and was a Currency field. When this field is created, a few things begin to happen:
-The event names change from the event title to the event url name (e.g. "Event 01" becomes "event-01").
-When I access the events programatically, events not from the primary data provider have a null title and the url name ("event-01") populates the description field.
-I begin to periodically get null reference exceptions when interacting with the non primary data provider events through the sitefinity backend.
When I remove the custom fields, the issues go away and I can interact with the events through the fluent API and the sitefinity backend. Is anyone else able to reproduce these issues?
Are these known issues and/or is there a different recommended path to using custom event fields while using multiple event data providers?
Thanks.
Hi Geoff,
Custom fields are supported per persistent type and not per provider. Actually, the user interface does not allow creating more than one custom field with the same name. Could you please describe the steps for creating fields with the same name in order to reproduce it locally?
Regarding the question for getting all providers, you could use EventsManager ProvidersCollection static property.
Greetings,
Pepi
the Telerik team
Thanks, Pepi, for the EventsManager.ProvidersCollection.
To create the custom fields, I created 2 event data providers (OpenAccessDataProvider and OpenAccessDataProvider2). OpenAccessDataProvider is the default event data provider. OpenAccessDataProvider2 points to my second Sitefinity site.
I navigated to Content -> Events and selected OpenAccessDataProvider, then in the right sidebar, I selected "Custom Fields for event".
I created a custom field named "Price" as a "Currency" type. I left all other options as their default values. I then saved changes.
I went back to Content -> Events and repeated the process for the OpenAccessDataProvider2 tab.
The UI did not prevent me from created this field for each data provider, but as soon as I created the custom field for OpenAccessDataProvider, the event names on OpenAccessDataProvider2 changed from event title (Event 01) to event url name (event-01).
Thanks.
Regarding custom fields, I have multiple event data providers across multiple Sitefinity sites and need to create custom fields, such as a Price field, to be used across all events from all sites. What is the recommended approach to accomplishing this? Is there a way to share the custom fields across sites? Do I need to recreate them on each site?
Pepi, have you been able to duplicate the issue that I described in my last post?
Thanks.
Hi Geoff,
Actually, our QAs reproduced the following issue and here are the steps:
1. Add two custom providers for Events (the second one points to another database)
2. Create a custom field for the default provider. Note that this field is visible under the second provider and the UI does not allow adding it twice.
3. Go and edit the events under the second provider. The result is that they throw "Object reference not set to an instance of an object" exception. Creating a new event also results in an error message. Note that this is not reproducible for the default provider events.
The described problem was logged as a bug and its fix will be available in upcoming Q1.
Greetings,
Pepi
the Telerik team
Thanks for keeping me up to date, Pepi.
That sounds accurate from what I've seen. So to make sure I'm understanding correctly, this issue will be resolved in the Q1 release, which is scheduled for April 4th? After this release, I will then be able to use custom fields with multiple event data providers? I have a project due very shortly after your scheduled release of April 4th and managing events are a core function of my client's site, so I want to make sure I have a planned solution to this issue.
Thanks.
Hi Geoff,
I confirmed that the issue described in my previous post will be fixed in Q1. The custom fields will work correctly with custom providers. This means that:
1. Custom fields created for the default provider will be available in the custom provider as well
2. Events under the custom provider will be properly saved/created
I just want to add that Q1 is scheduled for 13th of April (the release is postponed by a week).
Greetings,
Pepi
the Telerik team
Everything working great in this scenario EXCEPT the taxonomy....
Added connectionString property and get this when navigating to taxonomy in Backend
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
|
Now that 4.1 SP1 has been released, I have to return to this thread. In 4.0 SP1, custom fields did not play well with multiple content providers. I was not able to upgrade to 4.1 because of several of the bugs, so 4.1 SP1 is the first release where I have been able to test this.
Can someone point me to documentation regarding using custom fields with multiple content providers and also, hopefully, answer my questions below? Thanks.
I set up SiteA and SiteB.
SiteA contains ProviderA (pointing to SiteA) and ProviderB (pointing to SiteB).
SiteB contains ProviderA (pointing to SiteA) and ProviderB (pointing to SiteB).
I set up custom fields on SiteA for ProviderA. When I switch to SiteA ProviderB, the custom fields automatically appear there as well. Is this expected behavior?
If an event is created on SiteA for ProviderB, does this event get persisted in the database for SiteA or SiteB?
If SiteB does not contain the custom fields defined in SiteA for ProviderB, where does this metadata go?
When I create an event on SiteA for ProviderB, the event does not show up on SiteB for ProviderB. This previously worked and I was able to create and share content across sites. Can anyone else reproduce this behavior?
Thanks.
Hi Geoff,
There is no documentation about this scenario, but we will add such.
I set up custom fields on SiteA for ProviderA. When I switch to SiteA ProviderB, the custom fields automatically appear there as well. Is this expected behavior?
Yes, it is expected behavior, because a custom field is valid for the whole type not only for a provider. So every provider for events will use the existent custom fields.
If an event is created on SiteA for ProviderB, does this event get persisted in the database for SiteA or SiteB?
The event for ProviderB is persisted in the database for SiteB together with the data of the custom fields for events defined in SiteA.
If SiteB does not contain the custom fields defined in SiteA for ProviderB, where does this metadata go?
If you create a custom field in SiteA then the metadata about this field will be persisted in the database for SiteA. Though the data of the custom field will be persisted as a table column in SiteA and SiteB as well. In order for SiteB to see the data stored in its database you have to create a custom field with the same name and type in SiteB.
When I create an event on SiteA for ProviderB, the event does not show up on SiteB for ProviderB. This previously worked and I was able to create and share content across sites. Can anyone else reproduce this behavior?
Would you make sure that the ProviderB for SiteA and ProviderB for SiteB share the same application name?
Regards,
Ivan Pelovski
the Telerik team
Thanks for your explanations. That helps me a lot in understanding how the system is supposed to work.
Regarding the applicationName value, the applicationName values of ProviderA and ProviderB on both SiteA and SiteB are all set to "/Events", which I believe is the default value. I assumed a common value for SiteA ProviderB and SiteB ProviderB was necessary for both sites to see the events. Maybe this is incorrect on my part.
Thanks.
Just to clarify from your last post Ivan, has documentation for this scenario been added yet?
We're trying to display events and their custom fields from SiteA and SiteB onto SiteC. From what I understand this is possible, is this correct?
Hi Mark,
The documentation is still in progress. It is possible to use custom fields with multiple website. Are you experiencing any problems?
Regards,
Radoslav Georgiev
the Telerik team
Does anyone from Telerik have feedback regarding my last post on the applicationName value of the configured data providers?
-Thanks
Hello Geoff,
Yes, you assume right that SiteA ProviderB and SiteB ProviderB need a common value in order for both sites to see the events. If you still experience problems to get the events shared by both sites than would you consider sending us the event config files of the sites. The files are named EventsConfig.config and are located at ~/App_Data/Sitefinity/Configuration.
All the best,
Ivan Pelovski
the Telerik team
To remove any issues that could be caused with using a site upgraded from 4.0, I created two new Sitefinity 4.1.1405.0 sites (SiteA and SiteB). I setup the second data providers for each site to point to the opposing site. This can be seen in each site's corresponding EventsConfig.png file attached to this post.
For SiteA, both data providers show up in the Events section (shown in SiteA.jpg), however only one of the two created events on SiteB show up for SiteA::SiteBDataProvider.
For SiteB, the second data provider (pointing to SiteA) is not showing up. You can see from the corresponding EventsConfig.png file, that this second data provider is configured. Does something specific need to be done to get this second data provider to show up? If so, why did this not need to be done on SiteA to get the SiteBDataProvider to show up?
Thanks.
Hi ,
1. Have you added connection string inside SiteB that points to SiteA using DataConfig?
2. Have you added connectionName parameter to the provider that points to SiteA? If this parameter is not added the provider won't appear.
Greetings,
Ivan Dimitrov
the Telerik team
applicationName data provider parameter on each site is set to "/Events".
connectionString data provider parameter on each site is set to a connection string pointing to the other site's database.
Those are the only 2 parameters I set on each data provider.
According to Ivan Pelovski, 'applicationName' should be set to the same value on all data providers in my scenario, so I believe "/Events"" is correct.
I created these sites specifically for this test, so they are brand new sites with minimal configuration changes. Also, both sites are configured the same way. That's what makes the differing behavior confusing to me.
What is the "connectionName" parameter?
I know you said there is not yet documentation outlining configuration of this scenario. Is there documentation available that discusses the possible parameter values and what they do?
Thanks.
Hello ,
When we initialize the provider we need two parameters - provider name and connection name
All the best,
Ivan Dimitrov
the Telerik team
Is "connectionName" different than "connectionString"?
As shown in the screenshots previously attached, one of the sites knows it has 2 data providers, the other site does not and only displays the default provider.
The site that shows both providers only shows one of the two events available through the second data provider. The fact that any of the events appear makes me believe that a connection is made, but why does only one show up and why does this only work on one of the sites when they are both configured in the same manner (pointing to the opposing site)?
Thanks.
Hi Geoff,
Apologies for the delayed answer.
I've recreated the setup locally. The problem you are experiencing is symmetric and this happen because each site caches its own data. Here is one solution that you can apply: Go to Administration>Setting>Advanced>Data and set EnableDataCaching=False. Then save and restart your application.
You need to use connectionString in the definition of the second provider(on both sites)
Do not forget to reset both applications.
Kind regards,
the Telerik team
Ok. I hate to sound like a dim bulb, but here goes...
<
contentConfig
xmlns:config
=
"urn:telerik:sitefinity:configuration"
xmlns:type
=
"urn:telerik:sitefinity:configuration:type"
config:version
=
"4.4.2117.0"
>
<
providers
>
<
add
title
=
"Old Site Data"
type
=
"Telerik.Sitefinity.Modules.GenericContent.Data.OpenAccessContentProvider"
connectionString
=
"Connect2OldSite"
enabled
=
"True"
name
=
"OldSite"
/>
</
providers
>
</
contentConfig
>