我正在为我的liferay 6.2构建一个freemarker主题,当我尝试访问没有所需权限的页面时,我正在获取登录portlet的窗口状态。在这种情况下,liferay"拦截"请求并在最大化窗口状态下在我的主页布局模板上呈现登录portlet(这是一个很好的行为)。
我的问题是我的家庭布局与我的其他布局模板不同。因此,portlet的外观和感觉都是错误的。
有没有办法检查登录portlet是否已呈现,以及是否获取viewmode以检查是否要呈现我的home布局?
到目前为止,这是我的家庭布局检查代码。 Todo-Comment就是我的目标。
<#-- Check whether layout template of current page is home layout. -->
<#assign isHomeLayout = false />
<#if themeDisplay.getLayout().getTypeSettingsProperty("layout-template-id") == "novofleet-home-layout">
<#-- TODO: CHECK FOR LOGIN PORTLET AND WINDOW STATE AND RETURN FALSE IF PORTLET IS RENDERED AS MAXIMIZED -->
<#assign isHomeLayout = true />
</#if>
答案 0 :(得分:1)
(从问题中提取的答案)
我刚通过Liferay的url params检查了最大化窗口状态是否有任何portlet。新代码:
<#-- Check whether layout template of current page is home layout. -->
<#assign isHomeLayout = false />
<#if themeDisplay.getLayout().getTypeSettingsProperty("layout-template-id") == "novofleet-home-layout">
<#assign isHomeLayout = true />
<#-- Check for existence of url parameter which forces portlets to maximezed window state and revoke home layout -->
<#assign maximized = request.getParameter("p_p_state")!"defaultValue" />
<#if maximized == "maximized">
<#assign isHomeLayout = false />
</#if>
</#if>