+1-888-365-2779
Try Now
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

3 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:
    07 Dec 2016
    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
3 posts, 0 answered