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 get layoutid on freemarker template liferay 7.4
hello devs, i need to know how to get layoutId in a freemarker template, i have this code on vm template on 6.2
##Take layout id
#set ($layoutId = $request.get("theme-display").get("plid"))
## get the service for layout
#set($layoutService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
##convert the layout id into long
#set ($layoutLong = $getterUtil.getLong($layoutId))
##take a layout object
#set($layout = $layoutService.getLayout($layoutLong))
#set ($pageName = $layout.getName($locale))
what would be the way to do this in freemarker?
I appreciate any recommendation.
it may help someone in the future.
<#--Take layout id-->
<#assign layoutId = themeDisplay.getPlid>
<#-- get the service for layout-->
<#assign layoutLocalService = serviceLocator.findService("com.liferay.portal.kernel.service.LayoutLocalService")>
<#--convert the layout id into long-->
<#assign layoutLong = getterUtil.getLong(layoutId)>
<#--take a layout object-->
<#assign layout = themeDisplay.getLayout()>
<#assign pageName = layout.getName(locale)>
<#setting locale = localeUtil.getDefault()>
<#assign journalArticleId = .vars['reserved-article-id'].data/>
<#-- get Date object-->
<#assign modifieddate = .vars['reserved-article-modified-date'].data>
<#-- get format Date-->
<#assign modDateFormat = modifieddate?datetime("EEE, d MMM yyyy HH:mm:ss Z")>
Powered by Liferay™