Expand my Community achievements bar.

SOLVED

restricting cq:dialog options on included child components

Avatar

Level 2

I have a composite component consisting of three included components an image a title and a text component. Normally since the title component inherits the `wcm/foundation/components/title` the data-sly-resource included component gets the title type option (h1,h2...) from it's parent. However for this specific composite component I want to limit the type option to just have h2 available. The Title component is included in the composite component like this:

<div data-sly-unwrap="${!wcmmode.edit}" data-sly-resource="${'title' @ resourceType='project/components/generic/title'}"></div>

This allows the content editor to edit the title in place.

My question is if it would be possible in some way to place cq:dialog restrictions on the title component that is included from the composite component to just allow the content editor to select h2?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Yes ,we do the same approach as Scott suggested.

First copy the JCR Dialog from the title component to your new component and modify according as per your requirement.

Hope this helps!!

Thanks,

Ratna Kumar.

View solution in original post

7 Replies

Avatar

Level 10

Hi,

If you need any variation to the existing component, you can overlay that component and create a new one and then use it.

else you may have to write some listeners to handle these restrictions at different places which personally I don’t prefer as it increases the complexity of  a component and also it’s maintenance.

thanks

Avatar

Level 2

this would also mean that I have multiple title components which do nothing but restrict the cq dialog options and would in my opinion also create complexity

Avatar

Level 10

I also prefer the 1-1 approach. Each  component has its own JCR branch that defines a dialog. This makes it easy to control which fields are used in a component dialog. As Lokesh mentions - if you want to do more complex stuff - you can write event listeners, etc.

Avatar

Employee Advisor

In my usecase, since H1-H5 styles are managed in styleguide, we use Generic Lists from ACS common to manage these lists. We created various variations based on the component context definitions (hero components title -> h1- h5, banner components  - h2->h5 etc)

Avatar

Level 2

when you say 1 on 1 approach how would you suggest doing this efficiently with as little duplication as possible ? for this instance with a title component

Avatar

Level 10

Copy the JCR Dialog from the the title component to your new component. Then make the modifications under your new component's dialog JCR nodes. That is the best way in my view. It works and cuts down on complexity.

Avatar

Correct answer by
Level 10

Hi,

Yes ,we do the same approach as Scott suggested.

First copy the JCR Dialog from the title component to your new component and modify according as per your requirement.

Hope this helps!!

Thanks,

Ratna Kumar.