Content load failes for dynamic modules with hierarchical structure
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);boolcontentChildren = dynamicModuleManager.HasChildItems(content);if(contentChildren) foreach(DynamicContent layer incontent.SystemChildItems) model.ErrorStep += 1; layers.Add(ParseLayerModel(layer)); dynamicModuleManager.LoadChildItemsHierarchy(content);
This did the trick I think
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
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?