Restricting component types within a (non template) container in Touch UI | Community
Skip to main content
Level 2
January 23, 2026
Question

Restricting component types within a (non template) container in Touch UI

  • January 23, 2026
  • 4 replies
  • 53 views

Hello!

I’ve hit a brick wall with something and hoping someone can help.

I have a component that has a drag and drop container. The container’s resource super type is core/wcm/components/container/v1/container

I want to restrict the components that can be dragged onto this container to a sub set of those allowed on the page, but can’t find a way to do that. Note: This component is not fixed to a template. It is optional on the page and is itself dragged onto a page container at author time.

Given it is not part of the template, I can’t use the template editor to set a policy to restrict components (that I can see). Essentially I’m stuck will allowing the set of components defined at page template level.

Is there a way to achieve this in Touch UI projects?

I recall this was easy in Classic UI projects, but not so much with Touch UI and editable templates.

Any help would be appreciated (Generative AI is no help - constantly hallucinating)

4 replies

PGURUKRISHNA
Level 4
January 24, 2026

Hey ​@ChrisPa12 

Yes, you can restrict components inside a drag-and-drop container even if the container is added dynamically.

How:
Give your inner container a custom resourceType (extending the Core Container) and create a Component Policy for that resourceType defining allowedComponents. AEM applies policies by resourceType — not only by template structure — so the restriction works even when the component is dragged onto the page.

If you leave it as the Core Container resourceType, it will always inherit the page’s container policy. A custom resourceType is the solution.

ChrisPa12Author
Level 2
January 27, 2026

Thanks for your response.

I can’t seem to get this working. I’ve replied to lavishvasuja below who suggested the same as yourself. I’d be grateful if you could take a look and see if I’m missing something simple.

Thanks

lavishvasuja
Level 3
January 25, 2026

@ChrisPa12 - 

In Touch UI, template policies only apply to containers defined in the template.

For author-added Core Containers, the recommended approach is to create a component-specific policy mapped to the container’s sling:resourceType. Define the allowed components in that policy under  /conf; AEM will enforce it even when the container is added at runtime.

cq:childEditConfig is a Classic UI pattern and isn’t reliable with Core Components—this method ensures consistent, predictable authoring behavior.

ChrisPa12Author
Level 2
January 27, 2026

Thanks for responding.

I believe have done this and the container is not restricted to the components I have defined in the policy. I can add all components that are allowed in the template I am using my component on.

My custom container overlays core/wcm/components/container/v1/container and has a resource type of my-project/components/my-container

In .content.xml under conf/my-project/wcm/settings/policies I have <my-project><components><my-container><my-container-policy> with the following properties

jcr:primaryType=”nt:unstructured”
jcr:title=”Custom container policy”
sling:resourceType=”wcm/core/componentspolicy/policy”
components=”[my-project/components/my-component1, my-project/components/my-component2]”

Also under that path there is a, empty <jcr:content jcr:primaryType=”nt:unstructured”/> node (this seems normal)

Every single article or example I can see then goes on to bind this to a template which is something I can’t do as the component that has my-container in its HTL isn’t part of a template and could be dropped many pages of differing template types.

Starting to think this isn’t possible (it certainly isn’t documented anywhere I can see 🤷🏻)

If you do have an example I’d be really grateful to see it

Thanks

ChrisPa12Author
Level 2
January 26, 2026

Thanks for the replies.

I had tried to create a policy linked to the resource type (I do have a specific container created for this purpose).

I must have done something wrong. I’ll try again and update this thread with the result.

ChrisPa12Author
Level 2
January 26, 2026

I haven’t gotten any further with this.

What I have is the following:

  1. A node at /conf/myproject/settings/wcm/policies/myproject/compoents/mycontainer/mycontainerpolicy
  2. The key properties on this node:
    1. sling:resourceType of wcm/core/components/policy/policy
    2. components - an array containing the path to the component I want to restrict to (note I have also tried allowedComponents without joy)
    3. policyResourceType myproject/components/mycontainer
  3. On the component node /apps/myproject/components/mycontainer I have a property cq:policy with value myproject/components/mycontainer/mycontainerpolicy

This isn’t working for me (my client is very security conscious so unfortunately I don’t dare copy the actual XML).

Can anyone correct my approach,  have a link to documentation, or an example in GitHub?

I’ve tried a slight variation based on what I saw in we.retail and one GitHub project I saw, but no joy :(