kontent-ai/java-packages

Adhere to linked items order when using multiple content types

Jmathieu3289 opened this issue · 2 comments

Motivation

When multiple content types are available within a linked items section of a model, the SDK does not maintain the order of the content in Kentico, but rather does an initial ordering by content type. This is due to how the StronglyTypedContentItemConverter works, treating referenced linked items as a map rather than a list.

    ModularContentElement modularContentElement =
        (ModularContentElement) item.getElements().get(contentItemMapping.value());
    Map<String, ContentItem> referencedModularContent = new HashMap<>(); // Could be made a list?
    for (String codename : modularContentElement.getValue()) {
        referencedModularContent.put(codename, modularContent.get(codename));
    }

Proposed solution

It would be nice to have the linked items maintain the order in Kentico so that specific content ordering is possible when using mixed types. Without this capability, additional code is needed to reorder the content manually after retrieving it from the SDK.

FYI, if this is grabbed for hacktoberfest, please perform a PR against the release/2.0 branch if prior to our 3.0 release.

Should be fixed in #88

  • feel free to reopen the issue if you found any issues