Automatic Custom Page Title from Title in Page Properties

Avatar

Avatar

shya

Avatar

shya

shya

16-02-2021

Hi Experts,

New in AEM.

I have to customize page title textfield at page properties using jcr:title (Title) string by appending some fixed string every time. Have to programmatically achieve this before saving the page properties to JCR. 

I am thinking to do this using JS, by assigning the pagetitle value before "SimpleSave" or "Save & Close" action is called. 

 

Where I can make this change if my approach is correct ? I am unable to find the location or there is any better way of doing that ?

 

Please reply.

 @kautuk_sahni @BrianKasingli @Arun_Patidar 

 

View Entire Topic

Avatar

Avatar

KiranVedantam1992

Avatar

KiranVedantam1992

KiranVedantam1992

17-02-2021

Hi @shya,

 

For your use-case, you can leverage Event handling functionality in AEM. We have multiple ways to do it and I will discuss one of the ways.

  • As you are creating a page, which is a JCR level event, write an Event Listener with the event Event.NODE_ADDED.
  • This listener will get triggered whenever there is a node of a particular type [in your case cq:page] added in the provided location [The content path where you are adding the page].
  • Inside the onEvent() method, fetch the page node via resource, get the title already added and saved by the author, and append the static text you need.
  • Also, this same action can be done via workflows [triggering them on particular content paths], schedulers [updating the content pages at a particular time], and so on...

For more info on the event listeners please visit my blog here.

 

Hope this helps.

 

Thanks,

Kiran Vedantam.