Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Creating custom template for teaser pages

Avatar

Level 4

When authors create Teaser Pages, by default they are set to use the default design. I'd like them to use the design I've specified for my code base, so I tried creating a new template to specify a resource type of the built-in teaserpage, but a design path for my project. As far as I can tell, this XML replicates the structure of /libs/cq/personalization/templates/teaser, but my new template is not showing up in the list of templates when I try to create a Teaser/Offer page under a Campaign.

Is this intended behavior?

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Template" jcr:title="Project Teaser Page" ranking="{Long}1000" jcr:description="Project sites should use this instead of the built-in Offer Page" allowedParents="[/libs/cq/personalization/templates/campaign,/libs/cq/personalization/templates/experience,/libs/cq/personalization/templates/offerlibrary]"> <jcr:content jcr:primaryType="cq:PageContent" sling:resourceType="cq/personalization/templates/teaserpage" cq:designPath="/etc/designs/client/project"/> </jcr:root>

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

Interesting, it worked for me !! Steps I followed

1. Copy and Paste the 'teaser' template.

2. Change the title and use the same teaserpage component as resourceType

3. I see my new template under campaigns when I click 'new'

Do you want to try copy/paste ??

View solution in original post

10 Replies

Avatar

Level 10

Hi Joel,

In your template, resourceType should map to a component which has a view, in your case you are mapped to another template !

Change sling:resourceType="cq/personalization/templates/teaserpage"

to sling:resourceType="cq/personalization/components/teaserpage"  and see if new template comes up !

Avatar

Level 4

Oh, that's embarassing! I did change that, though, and my template is still not appearing. I also tried adding the allowedPaths property as shown on /apps/geometrixx/templates/newsletter, and that also had no effect.

Avatar

Level 10

The resource type of a template references the component that is used for rendering the actual content. Therefore - it should always map to a component path. 

Avatar

Correct answer by
Level 10

Interesting, it worked for me !! Steps I followed

1. Copy and Paste the 'teaser' template.

2. Change the title and use the same teaserpage component as resourceType

3. I see my new template under campaigns when I click 'new'

Do you want to try copy/paste ??

Avatar

Level 10

Yeaa.. I just tried with using templates as the resourceType, though it lists the new template, it doesnt work when you create the offer. Its always better to map a component to a template which worked perfect for me !

Avatar

Level 4

Hm, I tried the copy and paste approach, and that's not working for me either.

I do have the ACS Commons library installed; I'm trying to see if there's anything in there that might have an effect.

Avatar

Level 4

OK, I turned on debug logging, and I get this for my template

"not allowed because not included in /content/campaigns/jcr:content/cq:allowedTemplates"

When you did the copy and paste, did you paste the new teaser template in the same folder as the built-in one (/libs/cq/personalization/templates)? That would explain why it worked for you.

Is there any official recommendations on risks of changing this property? Or perhaps defining my own folder for campaigns within the node structure of a site? That actually has a number of advantages, and I think would be easier for my authors to understand. I've always used /content/campaigns because that's where the templates I need will work. But if I'm defining one template already, maybe I go a little bit farther.

Avatar

Level 10

Yes Joel, I created under the same template folder !! that makes sense if you are creating it under a different folder.

Avatar

Level 2

I guess you can achieve this by Overlaying campaign, teaser and brand templates. I tried this and it worked for me. Here are the steps:
1. Copy /libs/mcm/templates/brand to /apps/cq/mcm/templates/brand and make the following changes
    a. Add /apps/cq/personalization/templates/campaign to allowedChildren
    b. Add /content/demo/campaigns to allowedPaths
    c. Give your custom "jcr:title" to your "brand" template
2. Copy /libs/cq/personalization/templates/campaign to /apps/cq/personalization/templates/campaign and make the following changes
    a. Add /apps/cq/mcm/templates/brand to allowedParents
    b. Add /content/demo/campaigns(/[^/]*)? to allowedPaths
    c. Give your custom "jcr:title" to your "campaign" template
3. Copy /libs/cq/personalization/templates/teaser to /apps/cq/personalization/templates/teaser and make the following changes
    a. Add /apps/cq/personalization/templates/campaign to allowedParents
    b. Give your custom "jcr:title" to your "teaser" template
4. Now create a "brand" under /content/demo/campaigns which is your custom path.
5. Then create a "campaign" inside brand.
6. Then create a "teaser" inside campaign.

There is no risk involved in the above process as per my knowledge.
Note: Official recommendation is not to create any custom components/templates/nodes etc under /libs/...
      The risk involved in this is "the content of /libs is overwritten the next time you upgrade your instance (and may well be overwritten when you apply either a hotfix or feature pack)". Reference: https://docs.adobe.com/docs/en/cq/5-6-1/developing/developing_guidelines_bestpractices.html

Avatar

Level 1

I am also facing same issue.

Please tell me what loggers (java class packages) you added to configure logging.