-
-
Save saulovenancio/93adadd10f8be40377295b765ff06664 to your computer and use it in GitHub Desktop.
AEM using Granite Render Conditions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<items jcr:primaryType="nt:unstructured"> | |
<widgetAlways | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This always shows" | |
name="./widgetAlways"/> | |
<widgetHeaderChrome | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This only shows when header "User-Agent" contains "chrome"" | |
name="./widgetHeaderChrome"> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple" | |
expression="${granite:containsIgnoreCase(header['User-Agent'], 'chrome')}"/> | |
</widgetHeaderChrome> | |
<widgetHeaderFirefox | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This only shows when header "User-Agent" contains "firefox"" | |
name="./widgetHeaderFirefox"> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple" | |
expression="${granite:containsIgnoreCase(header['User-Agent'], 'firefox')}"/> | |
</widgetHeaderFirefox> | |
<widgetHeaderOther | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This only shows when header "User-Agent" does not contain "chrome" or "firefox"" | |
name="./widgetHeaderOther"> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple" | |
expression="${!granite:containsIgnoreCase(header['User-Agent'], 'chrome') and !granite:containsIgnoreCase(header['User-Agent'], 'firefox')}"/> | |
</widgetHeaderOther> | |
<widgetSuffix | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This only shows with suffix "/foo/bar"" | |
name="./widgetSuffix"> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple" | |
expression="${granite:containsIgnoreCase(requestPathInfo.suffix, '/foo/bar')}"/> | |
</widgetSuffix> | |
<widgetSelector | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/select" | |
fieldLabel="This only shows with selector "bar"" | |
name="./widgetSelector"> | |
<items jcr:primaryType="nt:unstructured"> | |
<alpha | |
jcr:primaryType="nt:unstructured" | |
text="alpha" | |
value="alpha"/> | |
<bravo | |
jcr:primaryType="nt:unstructured" | |
text="bravo" | |
value="bravo"/> | |
</items> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple" | |
expression="${requestPathInfo.selectorString == 'bar'}"/> | |
</widgetSelector> | |
<widgetSelectorNotEmpty | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This shows with any selector string" | |
name="./widgetSelectorNotEmpty"> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple" | |
expression="${not empty requestPathInfo.selectorString}"/> | |
</widgetSelectorNotEmpty> | |
<widgetParam | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This only shows with querystring param "biz=baz"" | |
name="./widgetParam"> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple" | |
expression="${param.biz == 'baz'}"/> | |
</widgetParam> | |
<widgetCookie | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This only shows with cookie "bat=qux"" | |
name="./widgetCookie"> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/simple" | |
expression="${cookie.bat.value == 'qux'}"/> | |
</widgetCookie> | |
<widgetPrivilege | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This only shows if you can write to "/etc/workflow/instances"" | |
name="./widgetPrivilege"> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/coral/foundation/renderconditions/privilege" | |
path="/etc/workflow/instances" | |
privileges="jcr:write"/> | |
</widgetPrivilege> | |
<widgetNotLockedCanModfy | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This only shows when the suffix is not locked and can be modified" | |
name="./widgetNotLockedCanModfy"> | |
<rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/renderconditions/and"> | |
<not | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/renderconditions/not"> | |
<islocked | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="cq/gui/components/renderconditions/islocked" | |
path="${requestPathInfo.suffix}"/> | |
</not> | |
<canmodify | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="cq/gui/components/renderconditions/canmodify" | |
path="${requestPathInfo.suffix}"/> | |
</rendercondition> | |
</widgetNotLockedCanModfy> | |
<widgetCustomRenderConditionWeekend | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This only shows on weekends" | |
name="./widgetCustomRenderConditionWeekend"> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="renderconditiondemo/components/renderconditions/day" | |
days="[Sunday,Saturday]"/> | |
</widgetCustomRenderConditionWeekend> | |
<widgetCustomRenderConditionWeekday | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This only shows on weekdays" | |
name="./widgetCustomRenderConditionWeekday"> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="renderconditiondemo/components/renderconditions/day" | |
days="[Monday,Tuesday,Wednesday,Thursday,Friday]"/> | |
</widgetCustomRenderConditionWeekday> | |
<widgetCustomRenderConditionHasProperty | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="granite/ui/components/foundation/form/textfield" | |
fieldLabel="This only shows if "/content/renderconditiondemo/en/jcr:content/par/text" has property "text"" | |
name="./widgetCustomRenderConditionHasProperty"> | |
<granite:rendercondition | |
jcr:primaryType="nt:unstructured" | |
sling:resourceType="renderconditiondemo/components/renderconditions/hasProperty" | |
resourcePath="${requestPathInfo.suffix}" | |
propertyName="text"/> | |
</widgetCustomRenderConditionHasProperty> | |
</items> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment