Content load failes for dynamic modules with hierarchical st

Posted by Community Admin on 04-Aug-2018 12:42

Content load failes for dynamic modules with hierarchical structure

All Replies

Posted by Community Admin on 06-Mar-2014 00:00

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: www.sitefinity.com/.../getting-and-setting-parent-items

Posted by Community Admin on 06-Mar-2014 00:00

dynamicModuleManager.LoadChildItemsHierarchy(content);

 

This did the trick I think

Posted by Community Admin on 08-Mar-2014 00:00

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

Posted by Community Admin on 17-Nov-2017 00:00

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?

This thread is closed