Expose String to Velocity Theme in Liferay for Social Media Tags (Open Graph)

332 views Asked by At

I would like to expose some Strings to the a velocity theme in the liferay framework in order to write some HTTP headers used for social network sharing. What is important is that my Controller has to put these Strings to the velocity theme during the render phase.

How can this be done please?

2

There are 2 answers

2
Sandeep Nair On

You can always create a custom hook and add custom variable that will be available in theme. Check this link http://www.opensourceforlife.com/2012/06/custom-velocity-variable-in-liferay-61.html

3
Prakash K On

I think the utility class VelocityVariablesUtil should help you insert some variables or custom helper utilities to be accessed from the template (*.vm) file of theme.

You can use the insertVariables() method of this class in your controller to achieve what you need.

Let me know if this works.