Limit Child Node Type by Instance of Parent Node T...
# help-with-umbraco
r
I have setup where I have a Document Type that uses all of the same information, but the child-types of the parents have different properties. I want to limit the available child node type per instance of the parent node. For example: Parent Type: Sports Types of Sports: Baseball, Basketball (Use same properties, like description, number of fans, number of teams) Child Type: Players & Stats Baseball Player Stats: Name, Home Runs, Batting Average Basketball Player Stats: Name, Rebounds, Points I have figured out how to make all of the Document Types to display the information correctly, but I am able to create a baseball player under basketball and vice versa. How do I set up limits so that only Basketball Players can be created under Basketball and Baseball Players under Baseball without having to create two Doc Types for each one? https://cdn.discordapp.com/attachments/1334933280503496798/1334933280742707241/Screen_Shot_2025-01-31_at_11.59.46_AM.png?ex=679e54ff&is=679d037f&hm=4569a1563574fea78639f1a77640f0da9bfa3ec3c511daff2ff781e6b09e1d1e& https://cdn.discordapp.com/attachments/1334933280503496798/1334933281552203868/Screen_Shot_2025-01-31_at_12.00.31_PM.png?ex=679e5500&is=679d0380&hm=28ff82da8100280d95800ad025417acaca3abc338dd7b37d140fc58118afc643&
r
That’s something that Clip may be able to solve! I’m not 100% but I know it allows content restrictions https://marketplace.umbraco.com/package/clip.umbraco
a
I'd be tempted to rename the existing type to a "Player Group" and then create new document types extension for "Baseball Players" and "Basketball Players" separately.
r
@rickbutterfield Clip does not do what I am looking for. Thanks for the suggestion.
@Andrew McKaskill You are probably right for my example, but that was the best way I could explain the data/functionality of what I'm actually trying to do.
c
You'll need to create separate "parent" types for this - but you can put their properties in a Composition so you're able to manage their common properties in one place.
a
Ah, ok. I remember Callum showed an example at a meetup where he had a single document type but was restricting which blocks were available in the blocklist inside it based on some custom logic. I'm fuzzy on the specifics, but I'll ask him.
@Jason was there too. Do you have any insight or remember which example I'm thinking of?
j
Yeah, we use that a fair bit, it uses the SendingContentNotification and modifys the available blocks based on its blueprint. Not sure it will help here. This is a job for the SendingAllowedChildrenNotification https://docs.umbraco.com/umbraco-cms/13.latest/reference/notifications/sendingallowedchildrennotifications
l
Beware that there is currently nothing in Umbraco 14 and 15 to do the same, although in 15.2 this should be added that makes it possible again: https://github.com/umbraco/Umbraco-CMS/pull/18029
r
Can you send me a link to the compositions? I would like to read up on them.
@Andrew McKaskill @Luuk Peters (ProudNerds) @Jason Thanks for this info. I will have to read up on it and see if I can get it to do what I want. Is there a date for 15.2?
@Jason @Luuk Peters (ProudNerds) So that pull request almost does what I want it to, only it is lacking the document ID, which is what I need to correctly filter the child documentTypes. I have found the TS code that that receives this information, and based on that class, I think it would be easier to filter the results in the TS. It might be easier to create new filter that takes this extra information, but I am having trouble finding the API where the TS integrates with the CS. Does any of this make sense to you? Is there any other advice you would be able to provide for me to help accomplish this?
7 Views