Hiding a dialog checkbox when component used in a specific Template structure? | Community
Skip to main content
Level 6
December 22, 2023

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

  • December 22, 2023
  • 1 reply
  • 1016 views

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"/>

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

1 reply

Mahedi_Sabuj
Community Advisor
Community Advisor
December 22, 2023

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.

Mahedi Sabuj
anasusticAuthor
Level 6
January 4, 2024

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>