Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Design .content.xml node writing guidelines for components (Sling ressource type path)?

Avatar

Level 1

Hi @all,

sorry, for rusty english. I'll do my best ;).

Given example: a node from the designs .content.xml:

<stage jcr:primaryType="nt:unstructured" sling:resourceType="ORG/components/stage" dontUseTargetValues="true" hideTargetValuesPolicy="[jcr:description]" stage.renderMode="general"> <par jcr:primaryType="nt:unstructured" sling:resourceType="foundation/components/parsys" components="[/apps/ORG/components/image,/apps/ORG/components/teaser,/apps/ORG/components/text/textimage]"> </par> </stage>

If the components increase (in combintaion with the Sling ressource type path), the readability of this line will decrease. This will become very difficult and hard to maintain. Is it allowed to write those "components" lines like this?

<stage jcr:primaryType="nt:unstructured" sling:resourceType="ORG/components/stage" dontUseTargetValues="true" hideTargetValuesPolicy="[jcr:description]" stage.renderMode="general"> <par jcr:primaryType="nt:unstructured" sling:resourceType="foundation/components/parsys" components="[ /apps/ORG/components/image, /apps/ORG/components/teaser, /apps/ORG/components/text/textimage ... etc. ]"> </par> </stage>

Is AEM/CRX able to interpret those lines correctly? Is this a valid way to write this XML node entry?

Thanks for your help and any suggestions.

Eddie (Greetings from germany)

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

Go ahead and try it, but my guess is that it will not work. I know if you put a space between the comma delimited list items, it will not work. And, unfortunately the almost silent failure is that the property just simply isn't set in CRX. You'll need to pay close attention to whether your XML file was appropriately deployed as nodes/properties.

Are you aware of component groups? The best practice is to place your components in groups, then specify which groups are allowed in the design. That allows you to keep things much simpler and you don't have to add components to the design every time (as long as they are in the group).

On the component definition itself set the property "componentGroup" to whatever value...typically one group that corresponds with the name of your site/organization is enough. Then in the "components" property on your paragraph system node in the design configuration, instead of using a path to a component, specify "group:MyGroup". Then all components in that group will be allowed, per the design.

Note, I've also had issues with line delimiting the XML namespace declarations for a .content.xml file. When I do that it will deploy an nt:file node called .content.xml instead of translating them to JCR nodes.

You may want to double check my syntax - it's off the top of my head - but component groups should help you clean things up.

View solution in original post

1 Reply

Avatar

Correct answer by
Former Community Member

Go ahead and try it, but my guess is that it will not work. I know if you put a space between the comma delimited list items, it will not work. And, unfortunately the almost silent failure is that the property just simply isn't set in CRX. You'll need to pay close attention to whether your XML file was appropriately deployed as nodes/properties.

Are you aware of component groups? The best practice is to place your components in groups, then specify which groups are allowed in the design. That allows you to keep things much simpler and you don't have to add components to the design every time (as long as they are in the group).

On the component definition itself set the property "componentGroup" to whatever value...typically one group that corresponds with the name of your site/organization is enough. Then in the "components" property on your paragraph system node in the design configuration, instead of using a path to a component, specify "group:MyGroup". Then all components in that group will be allowed, per the design.

Note, I've also had issues with line delimiting the XML namespace declarations for a .content.xml file. When I do that it will deploy an nt:file node called .content.xml instead of translating them to JCR nodes.

You may want to double check my syntax - it's off the top of my head - but component groups should help you clean things up.

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----