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
Solved! Go to Solution.
Views
Replies
Total Likes
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" }"/>
or you can create your own custom rendercondition
https://medium.com/@arunpatidar26/custom-render-conditions-in-aem-392cae88a800
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"]
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!
From what you shared, you’re using a granite/ui/components/coral/foundation/renderconditions/and with two conditions:
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>
The regex render condition checks the page path against a pattern:
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:
But honestly, unless you need something super specific, the regex trick should be plenty.
Pop that XML into your dialog, deploy it, and test it on a few pages:
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
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>
Views
Replies
Total Likes
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.
<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:
Views
Replies
Total Likes
Sorry for late reply. Tried below options. Still, no luck.
I dont want to use any custom servlet option.
My lang code path is here.
path.startsWith('/content/abcd/efgh') expression will not work with page properties because because page property url does not start with /content.
you need to try with something like 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" }"/>
for dynamic logic you can rely on
granite:relativeParent("/a/b/c/d", 1) == "/a/b/c"
Example
granite:relativeParent(paramValues["item"][0], 4) == ""
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" }"/>
or you can create your own custom rendercondition
https://medium.com/@arunpatidar26/custom-render-conditions-in-aem-392cae88a800
<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>
@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!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies