adobe / aem-core-wcm-components

Standardized components to build websites with AEM.
https://docs.adobe.com/content/help/en/experience-manager-core-components/using/introduction.html
Apache License 2.0
743 stars 750 forks source link

Unable to add ClientLibs: Template has no structure support #100

Closed B3r closed 6 years ago

B3r commented 6 years ago

Hello everyone! Could you tell me, what purpose template.hasStructureSupport() has got? (see line 271 below) And what I need to do, to use the populateClientlibCategories functionality?

Basically I want to include my own clientLibs by using the default page/head.html and the default page/footer.html instead of overwriting customfooterlibs.html and customheaderlibs.html

Would that be possible? All that's keeping me from doing that, is this template.hasStructureSupport. Is it true for editable Templates? Then why would that functionality be forbidden for static Templates?

https://github.com/Adobe-Marketing-Cloud/aem-core-wcm-components/blob/d34ee8f91bad08498a2f6a3fd3a01d6ddfea366f/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/PageImpl.java#L268-L279

Thanks for any advice! Greets, B3r

vladbailescu commented 6 years ago

The page component is designed to work with editable templates which allow configuration by policies. We can thus define in the policies what extra clientlibs are to be included:

https://github.com/Adobe-Marketing-Cloud/aem-core-wcm-components/blob/master/content/src/content/jcr_root/apps/core/wcm/components/page/v1/page/_cq_design_dialog/.content.xml#L25-L34

and add those in

https://github.com/Adobe-Marketing-Cloud/aem-core-wcm-components/blob/master/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/PageImpl.java#L287-L291

B3r commented 6 years ago

Thank you for your answer. However, it would be possible to use the page component for static templates. You could set the currentstyle in a static manner via etc/designs/<project>/.content.xml

Here an example:

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
  xmlns:cq="http://www.day.com/jcr/cq/1.0"
  jcr:primaryType="cq:Page">
  <jcr:content
    jcr:primaryType="cq:PageContent"
    jcr:title="Some Title"
    cq:template="/libs/wcm/core/templates/designpage"
    sling:resourceType="wcm/core/components/designer">
    <template_name jcr:primaryType="nt:unstructured"
      appResourcesClientlib="my.clientlib.category"
      clientlibs="my.clientlib.category"/>
  </jcr:content>
</jcr:root>

So basically in this example, the only difference between my static template and an editable template is the StructureSupport? Am I correct? Could that be an enhancement?

Thanks for your thoughts! Greetings, B3r

gabrielwalt commented 6 years ago

Hi @B3r, editable templates are a requirement for the Core Components. Unfortunately we won't be adding support for static templates with the Core Components as we are generally moving over to editable templates in AEM. At some point we might however create a migration script to transform static templates to editable ones.