Render condition for page dialog property | Community
Skip to main content
Level 7
February 21, 2025
Solved

Render condition for page dialog property

  • February 21, 2025
  • 4 replies
  • 1507 views

Hello Team,

 

I have a page property checkbox, that should be visible only in my language pages.

example: 

/content/abc/us/en
/content/abc/us/fr
/content/abc/gb/en

It should not be visible for other projects. (Since the editable template is used for other projects too)

property should be visible in 4th node. i.e /content/abc/us/en not in other child pages. example: /content/abc/us/en/home/service

 

I tried this logic. But this is failing. Can someone help me?

<isMyCheckbox jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/checkbox" text="Is ABC" name="./istesting" value="{Boolean}true" uncheckedValue="{Boolean}false" checked="{Boolean}false"> <granite:rendercondition jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/renderconditions/and"> <conditions jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/renderconditions/property" propertyName="path" propertyValue="/content/abc"/> <conditions jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/renderconditions/property" propertyName="pathSegmentCount" propertyValue="4"/> </granite:rendercondition> </isMyCheckbox>

 

cc @arunpatidar  @amitvishwakarma @sureshdhulipudi @raja_reddy 

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

Hi @mahesh_gunaje 

You can try below


 

<granite:rendercondition jcr:primaryType="nt:unstructured" sling:resourceType="/libs/granite/ui/components/coral/foundation/renderconditions/simple" expression="${paramValues["item"][0] == "/content/abc/us/en" || paramValues["item"][0] == "/content/abc/us/fr" || paramValues["item"][0] == "/content/abc/gb/en" }"/>

 

 

if this does not work, then try to use 

 

<granite:rendercondition jcr:primaryType="nt:unstructured" sling:resourceType="/libs/granite/ui/components/coral/foundation/renderconditions/simple" expression="${granite:url(paramValues["item"][0]) == "/content/abc/us/en" || granite:url(paramValues["item"][0]) == "/content/abc/us/fr" || granite:url(paramValues["item"][0]) == "/content/abc/gb/en" }"/>

 

 

https://developer.adobe.com/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/granite/ui/docs/server/el.html 

 

or you can create your own custom rendercondition 

https://medium.com/@arunpatidar26/custom-render-conditions-in-aem-392cae88a800 

4 replies

Level 4
February 21, 2025

hi @mahesh_gunaje ,

Hope you have find a solution for the above ask. If not few options below.

1. We can create a custom template for those specific language pages and add the checkbox in that template so it will be unique

2. you can write a custom java script and include that in a client library. Ensure the client library is of the cq.authoring.dialog category.

and add the client library in the component dialog 

extraClientlibs (String[]) = ["your-project.components.page.clientlibs"]

 

partyush
Community Advisor
Community Advisor
February 21, 2025

Hi @mahesh_gunaje 

I saw your question about the AEM page property checkbox, and I think I can help you out. You want it to show up only on specific language pages like /content/abc/us/en, /content/abc/us/fr, and /content/abc/gb/en (at the 4th level), but not on deeper pages like /content/abc/us/en/home/service or in other projects using the same editable template. Your current logic is a good start, but it’s not quite working, right? Let’s figure this out together!

What’s Going Wrong

From what you shared, you’re using a granite/ui/components/coral/foundation/renderconditions/and with two conditions:

  • Checking if the path starts with /content/abc — this part’s fine, but it’s too broad since it’ll match deeper pages too.
  • Using pathSegmentCount to limit it to level 4 — problem is, pathSegmentCount isn’t something Granite UI recognizes out of the box, so that’s probably why it’s failing.

A Simpler Fix

I’d suggest using a regex-based render condition. It’s quick, doesn’t need custom code, and should do exactly what you want. Here’s how I’d tweak your dialog XML:

<isMyCheckbox jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/checkbox" text="Is ABC" name="./istesting" value="{Boolean}true" uncheckedValue="{Boolean}false" checked="{Boolean}false"> <granite:rendercondition jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/renderconditions/regex" expression="^/content/abc/[a-z]{2}/[a-z]{2}$"/> </isMyCheckbox>

Why This Works


The regex render condition checks the page path against a pattern:

  • ^/content/abc makes sure it starts with /content/abc.
  • [a-z]{2} matches a 2-letter country code (like us or gb).
  • [a-z]{2} matches a 2-letter language code (like en or fr).
  • $ ensures it stops there — no extra levels like /home.
  • So, it’ll work for /content/abc/us/en but not /content/abc/us/en/home or /content/xyz/us/en.

If You Want More Control

If regex feels too rigid or you think you’ll need fancier logic later, you could go with a custom render condition. I’ve done this before — you’d create a little Sling model under /apps to check the path exactly how you want. Something like:

  1. Add a node in /apps/myproject/components/renderconditions/languagePageCondition.
  2. Write a quick Java class to check the path (I can share code if you need it!).
  3. Point your dialog to that custom condition.

But honestly, unless you need something super specific, the regex trick should be plenty.

Try It Out

Pop that XML into your dialog, deploy it, and test it on a few pages:


  • /content/abc/us/en — checkbox should show up.
  • /content/abc/us/en/home — should be hidden.
  • /content/xyz/us/en — hidden too.

Let me know how it goes! If it’s still not working, maybe we can dig into your setup a bit more — like, are there any funky inherited properties or template overrides messing things up?


Thanks 🙂
🙂

Level 7
February 21, 2025

Hi @partyush 

Thanks for your quick help.

To be frank, my project has this structure

/content/abcd/efgh/xyz/{country-code}/{language-code}

{country-code}: Not just 2 character

I have used below logic. Still, not working. Not sure what I am missing.

<isMyCheckbox jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/checkbox" text="Is ABC" name="./istesting" value="{Boolean}true" uncheckedValue="{Boolean}false" checked="{Boolean}false"> <granite:rendercondition jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/renderconditions/regex" expression="^/content/abcd/efgh/xyz/[a-z]+/[a-z]{2}$"/> </isMyCheckbox>
partyush
Community Advisor
Community Advisor
February 21, 2025

Given your project structure /content/abcd/efgh/xyz/{country-code}/{language-code} where {country-code} is not just 2 characters (e.g., usa, india) and {language-code} is 2 characters (e.g., en, fr), and the checkbox should only appear at this exact 5th node level (not deeper), here’s why your logic might be failing and how to fix it.

    1. Case Sensitivity: Your regex ^[a-z]+/[a-z]{2}$ assumes lowercase. If your paths have uppercase (e.g., USA, EN), it won’t match.
    1. Dialog Path Context: In a page properties dialog, the path might include /jcr:content (e.g., /content/abcd/efgh/xyz/usa/en/jcr:content), and your regex doesn’t account for this optional suffix.
    1. Regex Scope: Your regex correctly targets the 5th node, but it might not be evaluating the path you expect—verify the resource path in the dialog.
    • {country-code}: Variable length, mixed case (e.g., usa, India).
    • {language-code}: 2 characters, mixed case (e.g., en, FR).
    • Only 5th node (e.g., /content/abcd/efgh/xyz/usa/en), not deeper (e.g., /content/abcd/efgh/xyz/usa/en/home).
      <isMyCheckbox jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/checkbox" text="Is ABC" name="./istesting" value="{Boolean}true" uncheckedValue="{Boolean}false" checked="{Boolean}false"> <granite:rendercondition jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/renderconditions/regex" expression="^/content/abcd/efgh/xyz/[A-Za-z]+/[A-Za-z]{2}$"/> </isMyCheckbox>

      If it still doesn’t work:

      1. Check the Path: Add a log statement or use AEM’s debugger to confirm the exact path being evaluated (e.g., /content/abcd/efgh/xyz/usa/en or /content/abcd/efgh/xyz/usa/en/jcr:content).
arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
February 21, 2025

Hi @mahesh_gunaje 

You can try below


 

<granite:rendercondition jcr:primaryType="nt:unstructured" sling:resourceType="/libs/granite/ui/components/coral/foundation/renderconditions/simple" expression="${paramValues["item"][0] == "/content/abc/us/en" || paramValues["item"][0] == "/content/abc/us/fr" || paramValues["item"][0] == "/content/abc/gb/en" }"/>

 

 

if this does not work, then try to use 

 

<granite:rendercondition jcr:primaryType="nt:unstructured" sling:resourceType="/libs/granite/ui/components/coral/foundation/renderconditions/simple" expression="${granite:url(paramValues["item"][0]) == "/content/abc/us/en" || granite:url(paramValues["item"][0]) == "/content/abc/us/fr" || granite:url(paramValues["item"][0]) == "/content/abc/gb/en" }"/>

 

 

https://developer.adobe.com/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/granite/ui/docs/server/el.html 

 

or you can create your own custom rendercondition 

https://medium.com/@arunpatidar26/custom-render-conditions-in-aem-392cae88a800 

Arun Patidar
Level 7
February 28, 2025
Hello team,
 
I have found out the solution.
My project path: 
/content/abcd/efgh/xyz/{country-code}/{language-code}
 
I want below checkbox has to be visible only in locale pages.  
 

 

<isMyCheckbox jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/form/checkbox" text="Is ABC" name="./istesting" value="{Boolean}true" uncheckedValue="{Boolean}false" checked="{Boolean}false"> <granite:rendercondition jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple" expression="${granite:relativeParent(param.item, 3) == '/content/abcd/efgh'}"/> </isMyCheckbox>

 

 
Here, expression="${granite:relativeParent(param.item, 3) == '/content/abcd/efgh'}"/>
Meaning is checkbox has to be visible only in 3rd node after /content/abcd/efgh
So, after /content/abcd/efgh 3rd node is the locale one.
 

 

kautuk_sahni
Community Manager
Community Manager
February 28, 2025

@mahesh_gunaje Did you find the suggestions helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!

Kautuk Sahni