Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to pass data from Hook to theme's portlet_normal.vm file
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
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
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.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™