Display news from 2 providers in one widget?

Posted by bernd.basmer@terex.com on 06-Mar-2020 12:33

Hi.

I have assigned 2 news providers to a website to also show news from a different site. Now I'd like to show the news from both providers in the same widget. Is that possible? In the Advanced / Model dialog of the news widget I found the field where the provider is specified but I can't figure out how to add a second one there. If I do that, separated by comma, the second provider just gets ignored. Is there a way around that?

Thanks,

Bernd

All Replies

Posted by jread on 11-Mar-2020 21:31

it is possible to get results from multi providers and here a example but will have to write custom code or use the WebServices. below showing c# example.

MultisiteContext multisiteContext = SystemManager.CurrentContext as MultisiteContext;
			var allSites = multisiteContext.GetSites().ToList();
var providerList = new List<string>(); foreach (var site in allSites) { var siteProviders = site.GetProviders({{moduleName}});//Name of the module you would like to get the provider information for
foreach (var provider in siteProviders) { if (!providers.Exists(p => p.Name == provider.ProviderName)) { DataProviderInfo providerInfo = DynamicModuleManager.GetManager(provider.ProviderName) .ProviderInfos .Where(p => p.ProviderName == provider.ProviderName) .FirstOrDefault(); if (providerInfo != null) { //Provider exists, so do something with it like add it to a list to iterate over when calling a manager
providerList.Add(providerInfo.ProviderName); } } } }
var manager = NewsManager.GetManager();//gets manager with defaults
foreach(var providerin providerList){
manager = NewsManager.GetManager(providerName);
manager.GetItems()
}

This thread is closed