In this blog post I will share with you a specific Sitefinity use case and how to go about it.
“As a website administrators I want to have 3 different News modules just like the built-in Sitefinity News module because we have 3 different news authors who should have access to manage only their own news section.”
Make use of the Sitefinity provider model to create a total of 3 providers for the News module and set permissions for each news provider respectively.
News module providers can be created entirely through the Sitefinity admin interface in just 5 steps:
Login to Sitefinity CMS and go to Administration -> Settings -> Advanced settings
Locate News in the left panel and go to News -> Providers, then click on the Create new button in the right panel and fill the new provider properties
Title: Community News
Description: News about our user community.
Provider type: Telerik.Sitefinity.Modules.News.Data.OpenAccessNewsProvider
Make sure you check the Enable checkbox before saving the changes.
Select the newly created provider from the left panel and add an application name parameter for it
Repeat the steps to add one more provider with a different name (e.g. ProductNews) and different value for its applicationName parameter (e.g. /ProductNews)
Restart the website from the IIS web server for the changes to take effect. That's it!
You now have 3 different News providers that store news data in the same Sitefinity database and it is possible to assign permissions for each provider. The news data can also be manipulated through the API.
Let’s go to Content Types -> News to see our providers and create one news article under the CommunityNews provider.
Only users who have access to the CommunityNews provider will be able to manage this newly created article. You can set permissions for your issues by going to the Permissions link in the right panel of the screen above and selecting the respective provider to set its permissions.
Display news from a provider
News articles for different News providers can be displayed on Sitefinity pages utilizing the built-in News widget and all its features. To display our community news article on a page, you should add the News widget onto that page, click Edit and go to its advanced properties (bottom right corner of the edit dialog) and then go to the ControlDefinition button to update the ProviderName property of the widget with the name of the desired News provider.
The news widget will then display only news articles from the specified News module data provider. You can also leverage all its features such classification filters, sorting, paging, custom widget templates, and much more.
If you create custom fields for the News content type in general, these custom fields will be applied across all providers. But if all custom fields are the same for all news providers then this approach is perfect for our user story. In case you want to have different custom fields for the 3 different news sections, then you should develop a new content type for the two additional News module.
The provider approach is a very quick and easy way to separate and delegate News management to different stakeholders of the website. You don’t need to write a single line of code to do it.
What do you think about this approach? How do you find its use?