Setting meta properties in a page dynamically based on the component response

Avatar

Avatar

RejithaRaj

Avatar

RejithaRaj

RejithaRaj

19-03-2021

Hi,

 

I am trying to set the page meta properties dynamically based on the component used within the page. I would like to do it in the server side instead of client side.

Since the page meta properties are within the head html it will load before the component is rendered. (The component will have dynamic response based on different parameters . Here i am trying to use the same template for all dynamic components).

Is there a way to fetch the values from the component before it is rendered , so i can set the meta properties .

 

Accepted Solutions (0)

Answers (5)

Answers (5)

Avatar

Avatar

RejithaRaj

Avatar

RejithaRaj

RejithaRaj

22-03-2021

Dynamic response of a component is based on the query parameter or selector added to the page url like xx/xx.html?id=17411. Here we are having few dynamic components and i am using the same template for all of these. 

I am trying to invoke the call to these components from the page's head html where the meta properties are rendered.  If it was only one component i could have called the component directly from the page and get the meta properties needed. Since we have different dynamic components, I had to find the dynamic component used and had to invoke it through the code.

 

Or Is it better to have different templates for each dynamic components ?

Avatar

Avatar

snbaem

Avatar

snbaem

snbaem

21-03-2021

@RejithaRaj 

Usage of filter can be explored here. However there could be performance issues.

 

Avatar

Avatar

Jörg_Hoh

Employee

Total Posts

3.1K

Likes

1.1K

Correct Reply

1.1K

Avatar

Jörg_Hoh

Employee

Total Posts

3.1K

Likes

1.1K

Correct Reply

1.1K
Jörg_Hoh
Employee

19-03-2021

Hi,

 

to make this work you need a 2-pass rendering process, which Sling does not support ootb. Of course you could implement it somehow into Sling, but this would have consequences I cannot forsee. For example a lot of code would be executed twice, which normally should be executed just once. And much more.

 

A different option would be calculate these properties offline, with the drawback that they only reflect the outcome of the last rendering process. In that case a filter could collect all relevant information and store it a a page level. If you need to consider only activities of authors, this might even work (authors will always see the rendered page after their change). But of course your requirements might allow or not allow this.

 

Jörg

Avatar

Avatar

asutosh_j3

Avatar

asutosh_j3

asutosh_j3

19-03-2021

Hi @RejithaRaj 

Can you please provide more context on the different parameter with use case. Just want to make sure we understand the requirement completely before we suggest or think of anything.
Also as you mentioned it is going to be dynamic component and the metadata will change based on different parameter at server side, the page will not be cached at the dispatcher.

 

Thanks!

Avatar

Avatar

bilala23933647

Avatar

bilala23933647

bilala23933647

19-03-2021