More in this section
Forums / Developing with Sitefinity / Content load failes for dynamic modules with hierarchical structure

Content load failes for dynamic modules with hierarchical structure

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
4 posts, 0 answered
  1. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    06 Mar 2014
    Link to this post
    I have a question about how to get childs for
    a dynamic module.

    The code I have works, but sometimes the content.SystemChildItems
    returns null (for same object). Why is it only loaded sometimes?If I call the
    page 5-6 times, one of them will return null. It does not make sense. Can't I
    trust that the dynamicModuleManager.GetDataItem will load the objects or what
    am I doing wrong?



    Here are some code
    stringproviderName = string.Empty;
     
    DynamicModuleManager dynamicModuleManager =
    DynamicModuleManager.GetManager(providerName);
     
    Type sliderType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.Slider.Slider");
     
    DynamicContent item = dynamicModuleManager.GetDataItem(sliderType,
    SliderId);
     
    boolchildren = dynamicModuleManager.HasChildItems(item);
     
    if(children)
    {
        dynamicModuleManager.LoadChildItemsHierarchy(item);
        foreach(DynamicContent content initem.SystemChildItems)
        {
            // here the content.SystemChildItems is empty sometimes, but not always!
     
            foreach(DynamicContent layer incontent.SystemChildItems)
            {
                layers.Add(ParseLayerModel(layer));
            }
     
            slides.Add(ParseSlideModel(content));
        }
        ParseSlider(model,item);
    }


    I have tried to add this

    boolcontentChildren = dynamicModuleManager.HasChildItems(content);
     
    if(contentChildren)
    {
        foreach(DynamicContent layer incontent.SystemChildItems)
        {
            model.ErrorStep += 1;
            layers.Add(ParseLayerModel(layer));
        }
    }


    But then contentChilden is ALWAYS (??) false. I don't get it.

    Reference: http://www.sitefinity.com/documentation/documentationarticles/developers-guide/sitefinity-essentials/modules/dynamic-modules/hierarchical-dynamic-modules/getting-and-setting-parent-items
  2. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    06 Mar 2014
    Link to this post
    dynamicModuleManager.LoadChildItemsHierarchy(content);

     

    This did the trick I think

  3. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    06 Sep 2017
    08 Mar 2014
    Link to this post
    Hello Jan,

    Is this fix the issue you have?

    We highly appreciate shared solution with the community. Thank you for your involvement.

    Regards,
    Svetoslav Manchev
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
  4. Bini
    Bini avatar
    0 posts
    Registered:
    21 Aug 2017
    17 Nov 2017
    Link to this post

    Hi Team,

    I have the same issue. But it is not working even after applying your solution.

    I'm getting an exception while loading the function "LoadChildItemsHierarchy"

    Exception is :  "Cannot build a query with DynamicContent type. Actual childType is required."

    I'm passing the parent content item as parameter to the function "LoadChildItemsHierarchy".

    My code is :

    dynamicModuleManager.LoadChildItemsHierarchy(parentItem)

    I have no idea why it is happening. Anyone has any idea regarding why this exception is fired?

4 posts, 0 answered