Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Hiding a dialog checkbox when component used in a specific Template structure?

Avatar

Level 7

I have an experiencefragment component that has a checkbox. I want to show this checkbox by default in the editor dialog box and hide it only when this experiencefragment component is used in a structure for a specific template.

 

The problem is that I cannot disable this checkbox using the config provided here.

 

This is the template structure:

<root
jcr:primaryType="nt:unstructured"
sling:resourceType="xxx/components/structure/container">
<header
jcr:primaryType="nt:unstructured"
sling:resourceType="xxx/components/structure/header/feader"
editable="{Boolean}true"/>
<staging
jcr:primaryType="nt:unstructured"
sling:resourceType="xxx/components/content/experiencefragment"
editable="{Boolean}true"
cq:showOnCreate="{Boolean}false"/>
<main

 

This is the experiencefragment component _cq_dialog

<logout
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
name="./logoutPage"
text="Einsatz auf Logout Page"
value="{Boolean}true"
uncheckedValue="{Boolean}false"
checked="{Boolean}false"
cq:showOnCreate="{Boolean}true"/>

3 Replies

Avatar

Community Advisor

You can utilise design dialog to achieve the functionality.

_cq_design_dialog / .content.xml

<logoutDisabled jcr:primaryType="nt:unstructured"
  sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
  checked="false"
  name="./logoutDisabled"
  text="Disable Logout"
  uncheckedValue="false"
  value="{Boolean}true"/>

_cq_dialog / .content.xml  [add granite:hide property]

<logout jcr:primaryType="nt:unstructured"
  granite:hide="${cqDesign.logoutDisabled}"
  sling:resourceType="granite/ui/components/coral/foundation/form/checkbox"
  name="./logoutPage"
  text="Einsatz auf Logout Page"
  value="{Boolean}true"
  uncheckedValue="{Boolean}false"
  checked="{Boolean}false"
  cq:showOnCreate="{Boolean}true"/>

Finally, ensure to check the "Disable Logout" option of the Experience Fragment Component Policy for the specific template. This will hide the checkbox for that particular template.

Avatar

Level 7

Thank you so much for answering my question @Mahedi_Sabuj I am unfrtunatelly not able to set the "Disable Logout" to "true" using the Experience Fragment Component Policy for the specific template.

Avatar

Level 7

Hi @Mahedi_Sabuj 

The checkbox shows always and for all templates. It should not show for one specific template where the XF is part of the staging container:

 

<staging
jcr:primaryType="nt:unstructured"
sling:resourceType="xxx/components/content/experiencefragment"
editable="{Boolean}true"
cq:showOnCreate="{Boolean}false"/>

In the policy for that template I have:

<staging
cq:policy="xxx/components/structure/container/xf_staging_policy"
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/core/components/policies/mapping"/>

And additionally the policy looks like:

<xf_staging_policy
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/core/components/policy/policy"
logoutDisabled="{Boolean}true">
</xf_staging_policy>