+1-888-365-2779
Try Now
More in this section

Forums / Module Builder / Images are only filled after filtering

Images are only filled after filtering

4 posts, 0 answered
  1. David
    David avatar
    3 posts
    Registered:
    06 Jun 2014
    06 Jun 2014
    Link to this post

    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

  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    06 Jun 2014 in reply to David
    Link to this post

    Try this

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

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

  3. David
    David avatar
    3 posts
    Registered:
    06 Jun 2014
    10 Jun 2014
    Link to this post

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

  4. David
    David avatar
    3 posts
    Registered:
    06 Jun 2014
    12 Jun 2014
    Link to this post

    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.

4 posts, 0 answered