Copied to clipboard

Flag this post as spam?

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


  • Martin Nielsen 7 posts 87 karma points
    Jun 27, 2018 @ 12:59
    Martin Nielsen
    0

    Possible to add DocumentType inside another?

    Is it possible in a documenttype template (instance?) to include another documenttype.

    I know I can add a partial view but then there is no associated node for data.

    Right now I have a document type which loops it's children and then I do various logic including reading data from these children in order to display stuff. It seems wrong to place this logic in the top DocumentType. The logic should reside in the child. This would allow for better reuse of code.

    I'm thinking it is not possible because that would mean pointing to an instans of a document type in the definition of another...That also seems wrong. But it would be nice to be able to inject a documenttype instance into another one somehow. Like Sitecore with placeholders.

    Yes, what I want is what sitecore does where you can inject via placeholders!

  • Frans de Jong 548 posts 1840 karma points MVP 4x c-trib
    Jun 27, 2018 @ 13:15
    Frans de Jong
    100

    Documenttypes and templates are 2 seperate things. In essence a:

    • documenttype is for defining a definition
    • a content node uses a documenttype and here you can fill the fields defined in a documenttype
    • a template (view) is used to display the content.

    If you have a list of children in a template and you want to reuse the loop to show them you can do that with a partial view and include the partial view in every page where needed.

    If this doesn't answer the question please give a example of the site structure and the result you try to achieve.

    Frans

  • Martin Nielsen 7 posts 87 karma points
    Jun 27, 2018 @ 13:21
    Martin Nielsen
    0

    I guess that solves the problem although I would like code and data to be more tightly coupled. Just though that there might be a more elegant way. Probably not.

    That's why it would be nice to be able to inject a node (documenttype with template and node properties) into another node. Difficult to explain.

    Thank you for your answer.

  • Frans de Jong 548 posts 1840 karma points MVP 4x c-trib
    Jun 27, 2018 @ 13:28
    Frans de Jong
    0

    You could look into Nested content. This uses a documenttype that is "nested" in another. But that's not for children. Thats for repeatable data in a documenttype:

    Nested content documentation

    The power of Umbraco in my eyes is that I can access all the content everywhere I want.

  • Martin Nielsen 7 posts 87 karma points
    Jun 27, 2018 @ 13:43
    Martin Nielsen
    0

    That's just a list of document types where you access the data from your "main" doctype template, right? You are not using an associated template of the doctypes so that the node renders itself. I am basically doing something similar when I have the nodes af children.

  • Frans de Jong 548 posts 1840 karma points MVP 4x c-trib
    Jun 28, 2018 @ 07:13
    Frans de Jong
    0

    Yep

  • Martin Nielsen 7 posts 87 karma points
    Jun 28, 2018 @ 07:17
    Martin Nielsen
    0

    Ok, could still be useful and I did not know about it. Thanks for the tip!

Please Sign in or register to post replies

Write your reply to:

Draft