Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Carlos Gomes 38 posts 184 karma points
    Mar 22, 2019 @ 10:35
    Carlos Gomes
    0

    Getting IContent Children in v8

    Hi guys,

    I've been experimenting the Umbraco 8 in the past few weeks. We have created a custom Umbraco Event with the IComponent interface to create a new doc type on node pubished based on criteria. That is working well, the question here is: we want to create that document type under a folder that is under that that is being published and not under the page. I'm not seeing any method to return the Children of an IContent object in v8. Do you know if that's possible?

    Example:

    • Page 1

      • Folder

        • New doc type

    What we want to do is, when the Page 1 is published, we want to create the new doc type within the "folder" node. We could create the "new doc type" under the "page 1", but I'm not getting how can I create the new doc type within the "folder" node.

    Thanks for you help,

  • David Knittl 13 posts 114 karma points
    Mar 22, 2019 @ 14:14
    David Knittl
    0

    Using the ContentService you can get the children of a given node through

    Services.ContentService.GetPagedChildren(parentNode.Id, pageIndex, pageSize, out totalRecords)
    

    That works quite well for me.

  • Carlos Gomes 38 posts 184 karma points
    Mar 22, 2019 @ 20:19
    Carlos Gomes
    0

    Hi David,

    Thank you so much for your help on this.

    What are the correspondent values to the pagesize and pageindex input values of the GetPagedChildren method?

  • Carlos Gomes 38 posts 184 karma points
    Mar 23, 2019 @ 16:53
    Carlos Gomes
    0

    Hi guys,

    Just to let you know that I manage to solve this issue by using the GetById() method from the IContentService interface, where I passed the Model.Id of my folder.

    Thanks for your help on this David,

    Have you all a nice weekend,

Please Sign in or register to post replies

Write your reply to:

Draft