Images are only filled after filtering

Posted by Community Admin on 05-Aug-2018 13:55

Images are only filled after filtering

All Replies

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

Hey there,

I am developing a website with custom content types. I created the content types with the module builder (latest Sitefinity).

All custom content types contain images. I can see the images in the backend, after creating the items. When I am querying the items with
var dynamicModuleManager = DynamicModuleManager.GetManager(PROVIDER_NAME);
var editionType = TypeResolutionService.ResolveType(TYPE_NAME);
IQueryable<DynamicContent> allEditions = dynamicModuleManager.GetDataItems(editionType);

And getting the images with:
allEditions.First().DynamicContent.GetValue("Images");

the return value is an empty list. I also tried to cast them to ContentLink[] as mentioned here and here but this throws an exception. What works is a cast to ICollection<IDataItem>

In one of the content types there is an field of type Address. After filtering these items with:
((IGeoLocationManager)dynamicModuleManager).FilterByGeoLocation

the Images field is not empty anymore.

In other content types I do not have this option. Can someone help me?

Best regards,
David

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

Try this

dataItem.GetRelatedItems<Image>("Images");

...no more stupid dealing with ContentLinks...you get a list of pure image objects

Posted by Community Admin on 10-Jun-2014 00:00

I tried it, but the enumeration is empty. Just like I said.

Posted by Community Admin on 12-Jun-2014 00:00

Hey there,

when I am getting a single item with
dynamicModuleManager.GetDataItem(editionType, id);

the Images are present. Then I can use 
dataItem.GetRelatedItems<Image>("Images");

as suggested by Steve.

This thread is closed