Retrieving Data From Dynamic Modules Not Working - General Discussions - General Discussions - Progress Community
 General Discussions

Retrieving Data From Dynamic Modules Not Working

  • Retrieving Data From Dynamic Modules Not Working
  • Following the examples on this page:

    I've but the following code into the InitializeControls method in my, Thunder generated, widget with designer:

    1.protected override void InitializeControls(GenericContainer container)
    3.    var dynamicModuleManager = DynamicModuleManager.GetManager();
    4.    Type testimonialType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Testimonials.Testimonial");
    5.    var testimonials = dynamicModuleManager.GetDataItems(testimonialType).Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live);
    6.    dynamicContentListView.DataSource = testimonials;
    7.    dynamicContentListView.DataBind();


    But it yields no results, even though I have created two testimonials.  The only thing that is majorily different than the examples is that it is a multisite configuration.

    Am I missing something in this setup? Does it have to do with a multisite?


  • So you need to get the default provider for the current site and then use this provider when creating the DynamicModuleManager object.

    1.// Make sure we are using the provider for the current site.
    2. var provider = Sumo.Sitefinity.Framework.Model.MultisiteHelper.GetCurrentSite().GetDefaultProvider("Testimonials");
    3. string providerName = null;
    5. // the site doesn't have a default provider for 'Testimonials' so use the site provider.
    6.providerName = (provider != null) ? provider.ProviderName : DynamicModuleManager.GetDefaultProviderName(); ;
    7.DynamicModuleManager dynamicModuleManager = DynamicModuleManager.GetManager(providerName);

  • Hi,

    For DynamicModuleManager I am using this:

    var provider = new MultisiteContext().CurrentSite.GetDefaultProvider("MODULE NAME");

    Is there any way to get the module name using TypeResolutionService.ResolveType method? Module names can have spaces as well, so either we'll have to hard-code them in the code which is not a good practice at all. Or there must be some dynamic way for it.