Expand my Community achievements bar.

SOLVED

How to update a page template's initial page properties through code?

Avatar

Level 2

The project code has a property called contentType set under the following path 

 

 

/conf/<project>/settings/wcm/templates/<template_name>/initial/jcr:content

 

 

 

I am trying to update the value of the contentType but the changes are not getting updated in the aem instance after deploying the project in aem cloud.

 

Below is the initial page properties code for the template in the project before and after updating the contentType property:

Before:

 

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root jcr:primaryType="cq:Page">
 <jcr:content cq:template="<template_path>" 
              jcr:primaryType="cq:pageContent" 
              sling:resourceType="<page_component_path" 
              contentType="article">
 </jcr:content>
</jcr:root>

 

 

 After:

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root jcr:primaryType="cq:Page">
 <jcr:content cq:template="<template_path>" 
              jcr:primaryType="cq:pageContent" 
              sling:resourceType="<page_component_path" 
              contentType="">
 </jcr:content>
</jcr:root>

 

 

Is there any way to update the contentType property in a template's initial page properties?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @T_101 ,

 

It might be due to the filter configuration of your project. Try updating the mode for /conf or template path to "replace" in the project's filter.xml and deploy. Should most certainly work.

 

Thanks,

Fani

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

Hi @T_101 ,

 

It might be due to the filter configuration of your project. Try updating the mode for /conf or template path to "replace" in the project's filter.xml and deploy. Should most certainly work.

 

Thanks,

Fani

Avatar

Community Advisor

But I see contentType=“” as empty so it’s getting the value changed

Avatar

Community Advisor

 @DPrakashRaj  : Can you share the filter.xml file here.

 

and can you confirm , what change you are expecting in initial properties .

 

 contentType="article">

 this is existing and you want to make it blank as below.

 contentType="">

but after the code got deployed , the value is not getting updated as blank. is my understanding corect ?.

Thanks,
Siva

Avatar

Community Advisor

Hi @T_101 , Can you try updating the filter.xml for the template's filter path with mode as "update_properties" so that updated content / new content is taken and nothing is deleted.

Thanks,
Krishna