Try Now
More in this section

Forums / General Discussions / Retrieving Data From Dynamic Modules Not Working

Retrieving Data From Dynamic Modules Not Working

3 posts, 0 answered
  1. Guy
    Guy avatar
    2 posts
    08 Feb 2013
    08 Feb 2013
    Link to this post

    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?


  2. Guy
    Guy avatar
    2 posts
    08 Feb 2013
    12 Feb 2013 in reply to Guy
    Link to this post

    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);

  3. Saad
    Saad avatar
    98 posts
    10 Oct 2008
    18 Apr 2014 in reply to Guy
    Link to this post


    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.

3 posts, 0 answered