Skip to main content
Level 2
Jan 23, 2026 3:42 PM UTC

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

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)

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

9 replies

PGURUKRISHNA
Level 5
Jan 24, 2026 8:46 AM UTC

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.

Translate
Pagidala GuruKrishna
ChrisPa12Author
Level 2
Jan 27, 2026 11:16 AM UTC

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

Translate
lavishvasuja
Level 4
Jan 25, 2026 2:40 PM UTC

​@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.

Translate
ChrisPa12Author
Level 2
Jan 27, 2026 11:14 AM UTC

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

Translate
ChrisPa12Author
Level 2
Jan 26, 2026 9:50 AM UTC

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.

Translate
ChrisPa12Author
Level 2
Jan 26, 2026 4:54 PM UTC

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 :(

Translate
rk_pandian
Level 4
Feb 18, 2026 12:59 PM UTC

Hello ​@ChrisPa12! Even though you say that the component is not template specific, I think you still need a policy mapping in the potential templates where this component can land on. I tried everything you had mentioned and it finally worked only when I added the 

sling:resourceType="wcm/core/components/policies/mapping" property to the template where I had dropped the component.

The cq:policy property will point to the policy defined for this component.

Please try this and let us know if it helps.

 

Thanks!

Translate
Level 1
Feb 19, 2026 4:22 AM UTC

Have you added the cq:designDialog to include the allowed components as mentioned in here -

 

Translate
AmitVishwakarma
Community Advisor
Community Advisor
Feb 19, 2026 11:48 AM UTC

Hi ​@ChrisPa12 ,
The missing piece is that AEM still resolves the policy via the template, even for a container that’s added dynamically. Just creating the policy under /conf/.../settings/wcm/policies is not enough.

To restrict components in your custom container:

  • Define the policy (you already did this): Under /conf/myproject/settings/wcm/policies/myproject/components/mycontainer/mycontainerpolicy make sure you have for example:
    sling:resourceType = "wcm/core/components/policy/policy"
    components = ["myproject/components/my-component1", "myproject/components/my-component2"]

    (or allowedComponents – either is fine, but be consistent with Core Container usage).

  • Map the policy in each template where this container can appear:

    • In each relevant template under /conf/myproject/settings/wcm/templates/<template>/policies/... create a node, e.g.:

      /conf/myproject/settings/wcm/templates/<template>/policies/myproject/components/mycontainer
      sling:resourceType = "wcm/core/components/policies/mapping"
      cq:policy = "myproject/components/mycontainer/mycontainerpolicy"

      This is what actually tells AEM: “For resourceType myproject/components/mycontainer on this template, use that policy.”

    • Ensure your component has a design dialog (if you overlaid Core Container):
      In /apps/myproject/components/mycontainer include cq:designDialog (you can copy it from core/wcm/components/container/v1/container). Without this, the policy’s allowed components won’t be applied in the UI.

Once you add the policy mapping under the template and have a design dialog, the inner container will only allow the components from your policy, even though the container itself is dropped on the page at author time.
Thanks,
Amit

Translate
Amit Vishwakarma - Adobe Commerce Champion 2025 | 17x Adobe certified | 6x Adobe SME