How to update a page template's initial page properties through code? | Community
Skip to main content
New Participant
May 30, 2023
Solved

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

  • May 30, 2023
  • 3 replies
  • 1080 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Fanindra_Surat

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

3 replies

krishna_sai
New Participant
May 31, 2023

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

DPrakashRaj
New Participant
May 31, 2023

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

SivakumarKanoori
New Participant
May 31, 2023

 @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
Fanindra_Surat
Fanindra_SuratAccepted solution
New Participant
May 30, 2023

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