Current resource is used - which cannot work if a component is included from a template in /conf/ instead of /content/


I realize this might not be the correct project to send this issue in, but the generic Sling Context-Aware Configuration is also not a good place, since this is really an AEM-specific problem.

Whenever one puts a component in an editable template, that component gets placed in /conf/. When creating a page from that template, it could be that the component node is not copied to /content/, this can have various reasons (i.e. component being locked in the template, ...).

Here is where the problem occurs: When creating a ConfigurationBuilder, you'd normally use the resource, which can point to /conf. This results in CAConfig not being able to find the configuration.

Another similar problem occurs when using ${caconfig} in Sightly, it will also use the /conf path, instead of the /content path.

I have solved this problem a few times in my components by using ${currentPage} instead of ${resource}, but this more feels like a hack than an actual solution. + this still does not allow me to use ${caconfig} in HTL files.

I have thought about providing a context path strategy to also allow context paths to be found in /conf/ folders, but I quickly realized that things like the language are missing, i.e. I would be unable to build the correct context path in all cases.

So I feel this should be fixed maybe even in AEM itself, or additional tooling could be provided such as ${pageCaconfig} in HTL and indeed a guideline to use the currentPage instead of the resource when creating a ConfigurationBuilder.







Henry Kuijpers




Affects versions