GetModularContent not returning all ContentItems

So I've got a problem where I'm using the .GetModularContent to try and get an IEnumerable to grab a bunch of articles. However for some reason this seems to return my first content item but none of the others. Now if I look at the ContentItem I'm trying to run this on, I can see all the codenames pulled through in the Elements container.

I was wondering if anyone knew why this wasn't working as expected.

Comments

  • TechnicalSyndicutTechnicalSyndicut Member MVP
    edited August 2017

    Right this time I have figured out the problem. I was trying to get the modular content of a content item which itself was modular content of the actual Model being used, so for clarity:

    1. Start with an index content item
    2. Use this to get attached content
    3. Try to get modular content of the item grabbed at stage 2.

    Now unless this modular content was also present on the index page it wouldn't show up in the GetModularContent method, despite the codename being in the Elements object, of the content item in stage 2.

  • petrs@kentico.com[email protected] Eindhoven, NLMember, Administrator, Kentico Staff admin

    Have you tried altering the depth query parameter?

    Quoting from the documentation:

    Content items can contain Modular content elements and reference other content items. By default, only the first level of modular content is returned. If you need to exclude all modular content from the response, set the parameter to 0.

Sign In or Register to comment.