Defining a policy for parsys with dynamic node name | Community
Skip to main content
Level 2
March 13, 2018

Defining a policy for parsys with dynamic node name

  • March 13, 2018
  • 5 replies
  • 12304 views

Hello,

I am working on creating editable templates in AEM 6.2. I have an accordion-like component that leverages a multi-field to create tabs with parsys containers. In order to preserve the content that gets dragged into each of these parsys nodes, and to preserve the re-orderability that the multi-field provides, I've assigned each of the parsys nodes that get generated a unique ID that gets saved with the component.

I would like to make this available to the template editor, however the trouble I am facing is that I need to keep redefining a policy every time I add a tab. The problem with this is that I have to have a fixed number of tabs in my structure which is not acceptable.


This works fine however in the static templates. To get that working I added a list of allowed components to the design of the parent node that contains all of the dynamic parsys nodes. Each of the parsys nodes that get generated respect the list of allowed components defined on their parent.

I tried this approach using policies, but it does not work for me.

Can anyone offer any suggestions on how I can replicate what I've done with the static templates?

Thanks, Matt

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

5 replies

smacdonald2008
Level 10
March 13, 2018

I am still not 100% what you are asking. Can you show a screenshot of your component. I am not sure what you mean by dynamic node name.

Level 2
March 13, 2018

Hi Scott, I'll share with you the static template version that leverages /etc/designs/

Here is my component:

This component has a multi-field which creates "x" number of parsys nodes and dynamically adds a unique node name to them.

<div class="omc-Drawer-parsys" data-sly-resource="${['drawer-content', item.id] @ join='-', resourceType='foundation/components/parsys'}"></div>

Under /etc/designs, rather that trying to add a series of nodes below the omc-Drawer component and set the components[] for each, I am simply able to specify this property at the component level, like so:

I do it this way, otherwise I'd have to dynamically add the names of each generated parsys below omc-Drawer, ie:

- maincontent

     - omc-Drawer

          - drawer-content-6377

          - drawer-content-4452

          - etc...

This works well for static templates. I tried a similar approach with template editor and policies. But I am unable to replicate this behavior. I hope this cleared up any confusion.

Thanks, Matt

waynet7410269
May 23, 2018

What version are you using?


I'm using AEM 6.2

May 11, 2018

Hi mkinbaum27​ and waynet7410269
Don't know if the issue is still actual for you, but I faced exactly the same problem and found the way to resolve it without dirty hacks.
Problem:
I need to define a policy for the component which is container for other components. Purpose - to allow only particular components to be added inside this container component.

I added pretty similar policy as in post 4 https://forums.adobe.com/message/10240555#10240555

Result: policy worked fine for the first component added to a page, but did not work if to add second, third, etc components to the same page. The reason for that - first component has name MyComponent, when all added later components will be MyComponent-1111111, MyComponent-2222222 etc, and policy will be applied only for the first component with the name without any suffix - MyComponent.
Solution:
the matter is, that the nodes structure in your template-type and template itself must fully correspond to the structure of the defined policy. Let's take mkinbaum's example.
Current template structure:

templates

--matt-test

----policies

------jcr:content

--------root

----------omc_drawer

Must be:

templates

--matt-test

----policies

------jcr:content

--------root

----------foundation

------------components

--------------parsys

Hope that will help.

Adobe Champion
September 14, 2018

Has there been any update on this topic? I noticed the same issue exists with AEM 6.3.

February 4, 2019

I have run to similar issue in AEM 6.4.

I am creating policy and its only applied to the first element on the page.

Level 2
December 3, 2019

Having similar issue in AEM 6.4

Any workaround?

Level 2
January 26, 2020

Do we have any solution for this? I am facing same problem in AEM 6.4 SP6.

 

If we drop any component (let's say "MyComponent") which has its own inner layout-container/parsys and if we want to define policy for inner layout container of "MyComponent", then policy only worked fine for the first component added to a page, but did not work if we add second, third, etc components to the same page. The reason for that - first component has name MyComponent, when all added later components will be MyComponent-1111111, MyComponent-2222222 etc, and policy will be applied only for the first component with the name without any suffix i.e MyComponent.

Can anyone please help to fix this?

 

September 7, 2023

Still no solution to this problem?