Copied to clipboard

Flag this post as spam?

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


  • Morten 105 posts 345 karma points
    May 09, 2017 @ 09:22
    Morten
    1

    This content type is used in a composition already

    Hey, everyone. So I'm currently revamping my whole backend to use compositions instead of inheritance, but I have a question.

    Right now I have my Document Types like this:

    Master
        Home
        News page
            News article
    SEO Composition
    

    I have inheritance on my news page, because that makes most sense (right?). However. When I go to add my SEO composition to News page, I get this error:

    This content type is used in a composition, and therefore cannot be composed itself

    It is not being used in a composition already, but rather being a parent in an inheritance.

    • Is that why I get this error?
    • Should I make my News article Document Type into a composition instead?
    • Should I just create a folder called "Compositions" and move all compositions in there?

    Thanks!

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    May 09, 2017 @ 10:11
    Dave Woestenborghs
    0

    Hi Morten,

    This is because a inherited document is also a composition technically. Why can't you add the SEO composition to your master ?

    Dave

  • Morten 105 posts 345 karma points
    May 09, 2017 @ 10:15
    Morten
    0

    Because I get the same error. If I try to add SEO to the Master Document Type, I get the:

    This content type is used in a composition, and therefore cannot be composed itself

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    May 09, 2017 @ 10:22
    Dave Woestenborghs
    0

    Does your SEO composition inherits from another doctype. Or maybe it's using another doctype as composition ?

    Nested composition is not possible.

    Dave

  • Morten 105 posts 345 karma points
    May 09, 2017 @ 11:32
    Morten
    0

    My SEO composition is at the root of my Document Types. Completely isolated from everything else. My News page Document Type, however, is inheriting from the Master Document Type.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    May 09, 2017 @ 11:35
    Dave Woestenborghs
    0

    Does it work when you try to set it in the News Article doctype ?

    Dave

  • Morten 105 posts 345 karma points
    May 09, 2017 @ 11:40
    Morten
    0

    Yes.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    May 09, 2017 @ 11:46
    Dave Woestenborghs
    0

    Hi Morten,

    I think this is because technically speaking a doctype that is inherited is a composition itself. And you can't add composition to compositions.

    Dave

  • Morten 105 posts 345 karma points
    May 09, 2017 @ 11:49
    Morten
    0

    Well that sucks. I don't see the use for compositions then, if all my Document Types has to be placed in folders and have no connection to each other what so ever. What a bummer.

  • Jeff Subat 28 posts 159 karma points
    Jul 08, 2017 @ 20:07
    Jeff Subat
    0

    I agree. Composition and inheritance should work together. They don't today, and that seems rather short-sighted.

    For what it's worth:

    • It's possible to "trick" the user interface by adding your compositions to the parent type prior to creating any derived types from it. Of course, you need to know exactly what compositions you want in advance. You can, though, add properties to the compositions after-the-fact.
    • There is an issue in the tracker about this topic: Allow Compositions to be Composed of Compositions (i.e., Pseudo-Inheritance). It was created 18 months ago, though, so I don't think it's getting a lot of love.
  • John Bergman 483 posts 1132 karma points
    Sep 04, 2018 @ 06:45
    John Bergman
    0

    Bump. Just wondered if this was on the radar for anytime soon. It is pretty hard to refactor documents without having the ability to add a composition to a base document type that has derived types.... just saying.

    I have several cases where this would have come in handy now, and since I have a ton of content anyone have a recommendation on how to do this type of refactor?

  • Aaron 22 posts 93 karma points
    Jan 25, 2019 @ 09:24
    Aaron
    0

    Bump and second this, we also need to add compositions to a base document that has derived types.

    The derived types are associated with a load of content so we can't just delete and recreate them.

    To be fair we should have had better advance knowledge of what was required in the base type but this doesn't always happen IRL...

  • Frans de Jong 548 posts 1840 karma points MVP 4x c-trib
    Jan 25, 2019 @ 10:17
    Frans de Jong
    0

    We steer away from inheritance for a few years now. The real advantage in my eyes is using compositions and modelsbuilder together.

    Every composition has it's own partial class that you can use in partial views for common presentation. In this way you can really make modular code that you can easily pick up and reuse over your projects.

    In our older projects we just leave the documenttypes as is and don't use compositions until a rebuild is in play.

  • Aaron 22 posts 93 karma points
    Jan 25, 2019 @ 10:24
    Aaron
    0

    We use all three, compositions, inheritance and models builder.

    There are advantages to having polymorphic pages.

  • Frans de Jong 548 posts 1840 karma points MVP 4x c-trib
    Jan 25, 2019 @ 10:32
    Frans de Jong
    0

    What are the advantages to inheritance?

Please Sign in or register to post replies

Write your reply to:

Draft