Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

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

Avatar

Level 2

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 .

 

5 Replies

Avatar

Community Advisor

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

Employee Advisor

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

Community Advisor

@RejithaRaj 

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

 

Avatar

Level 2

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 ?