RE: How to pass data from Hook to theme's portlet_normal.vm file

Saurabh Khandelwal, modified 6 Years ago. New Member Posts: 14 Join Date: 1/18/19 Recent Posts
I'm working with Liferay 6.2I want to send some value from Blog portlet(ie. form jsp page) to  my custom theme (ie. my-theme\docroot\_diffs\templates\portal_normal.vm)
I have tried below code: 
1) Using Custom Velocity Variable
i. In File  view_entry.jspString Somevalue="Hello World";
Map< String, Object > vmVariables = (Map< String, Object > ) request.getAttribute(WebKeys.VM_VARIABLES);if ( vmVariables == null ) {         
    vmVariables = new HashMap< String, Object >();
}
vmVariables.put("saomKey", someValue);
request.setAttribute(WebKeys.VM_VARIABLES, vmVariables );
-------------------------------------------------------------------------------------------
ii. In file portal_normal.vm (Access velocity variable)
$someKey
But not working. Please give any solution for my scenario.
Thanks 
thumbnail
William Gosse, modified 6 Years ago. Liferay Master Posts: 533 Join Date: 7/4/10 Recent Posts
What part of the template are you trying to access your variable in? Is the header, footer, navigation, content area? I'm not sure how much the header and footer can be changed after the portal_normal.vm loaded. Are trying to display this variable. You may try moving your variable to the portlet vm which should gets loaded into the content area of the portal_normal.vm when you make a page change.  It's been a while since I've used 6.2 or velocity templates. With  version 7 the default template engine is now freemarker.