Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict entry types by parent/child relationship in structure section #1628

Closed
jordanlev opened this issue Apr 12, 2017 · 4 comments
Closed
Assignees
Labels
enhancement improvements to existing features

Comments

@jordanlev
Copy link

Creating a new issue for this, as per @brandonkelly in #853 ...

Would be great if there were a per-entry-type setting within a structure section to restrict the allowable entry types of children (or restrict entry types so they can only be children of certain parent entry types). Would offer similar benefits to restricting entry type by level in the hierarchy, but is conceptually simpler and offers more flexibility.

For example, if I have an employee directory and my entry types are "Employee" and "Department", I want each employee to be in 1 and only 1 department. I could set the section to only allow "Department" entry types at the top-level, then set the "Department" entry type to only allow "Employee" entries as children. (Or maybe it's vice-versa... saying that an entry type can only be a child of some other entry type, so a "Department" cannot be a child of any other type, and "Employee" can only be a child of "Department" entry type).

But if I have a more complex structure (to take an example from a real project I'm working on): I've got product categories and products. Categories can be nested, but products must be under 1 category (and a category either has sub-categories or sub-products, but not both). So I could have 3 entry types in this section: "category that has subcategories", "category that has products", and "product", then set each of them to only allow the children of the proper type (and set "product" to not allow child entries at all). In this way I can have an arbitrarily-nested structure (I don't have to set it to a specific number of levels) but also enforce the hierarchy I want.

@brandonkelly brandonkelly self-assigned this Apr 12, 2017
@brandonkelly brandonkelly added enhancement improvements to existing features feature request and removed enhancement improvements to existing features labels Apr 12, 2017
@fdelaneau
Copy link

Most of the time each level of a structure really has only one entry type so being able to set it automatically or define a default value would really help.

This would really make structures easier to explain to end users.

@kevadamson
Copy link

Hi. Did this ever get done? Looking for an option in entries field type that limits what can be selected to the top level ...

@brandonkelly
Copy link
Member

@kevadamson Check out the Level Entry Types plugin; it should work for your use case.

@kevadamson
Copy link

kevadamson commented Mar 29, 2021

Think I might have posted this on the wrong issue. Was actually thinking in terms of the entries field type. So when the user tries to choose an entry, they can only choose one from a certain structure level - if that makes sense.

I'm using the Level Entry Types plugin, in unison with the Child Me one. Works nicely for creating entries quickly in the right place with the right type.

@craftcms craftcms locked and limited conversation to collaborators Jun 22, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
enhancement improvements to existing features
Projects
None yet
Development

No branches or pull requests

4 participants