I need to create a hierarchy that looks something to the effect of

  • parent 1

    • parent 1 child 1
    • parent 1 child 2
    • parent 1 child 3
  • parent 2

    • parent 2 child 1
    • parent 2 child 2
    • parent 2 child 3

and so on. My initial thinking was to use the matrix field type....a lot but, unfortunately, a matrix field can't have child fields of matrix field, and each child will need a matrix due to not knowing how many items each one could have as well as keeping them all together and allow for easy reordering.

The other requirement is that a "child" can't exist without a "parent", so I essentially only want to allow a user to create a "parent" at the root level and "child" types under each parent.

Is this even possible in Craft? If it is, could you point me in the direction of where it's documented as I can't seem to find anything that resembles what I'm trying to achieve.

Thank you in advance


Sounds like a feature request for maximum number of levels in a structure.

But had a thought about this. Since structures have a level parameter, you could make a simple plugin to more or less restrict the number of levels you can have a structure. If it's more than 1, then set the page's parent to the top most parent, effectively limiting it to have that parent/child relationship.

Unfortunately, that'll only work on a "regular" entry save. If you move structures up and down in the admin—when not editing an entry— it looks like Craft doesn't call the onSave or onBeforeSave events. Bug perhaps?

  • Sort of, but also limiting what entry types can be created at each level. Essentially preventing "child" from existing at the root and "parent" existing under another "parent"
    – user4041
    Sep 8 '15 at 10:01

I came up with a less than ideal workout, but it's still somewhat of a solution

I first created a channel to contain all of the "child" entry types. This allowed each one to have a matrix property to account for the dynamic creation of the "child" fields

I then created another channel with an entry type that also contains an Entry select field which allows for unlimited selection of Entries of the "child" types


For very simple use cases, I've created a plugin that adds some validation to enforce this type of hierarchy: https://github.com/jordanlev/craft-EnforceDualHierarchy

If you'd like to see better / more robust functionality added to the Craft system in the future, please upvote this feature request: https://github.com/craftcms/cms/issues/1628


It's possible I'm misunderstanding, but aren't you just looking for a Structure Section?

It's like a Channel except that it allows for both order and hierarchy.

  • I did look into it, but a Structure allows for all entry types to be created at any level. I'm trying to restrict the root level to only allow for the creation of a "parent" which can only have "child" entry types. I've figured out a work around using a channel with entry types that contain a matrix of Entries, but it's not ideal
    – user4041
    Sep 7 '15 at 15:20
  • 1
    Fair enough... would you mind posting your workaround as an answer for other people?
    – Brad Bell
    Sep 7 '15 at 15:38
  • Sure, I'll create a new response
    – user4041
    Sep 7 '15 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy