Search code examples
liferayliferay-themeliferay-6.2

Liferay Theme: get Portlet Window State


I'm building a freemarker theme for my liferay 6.2 and I'm struggeling with getting the window state of the login portlet when I'm trying to access a page without the needed permissions. In this case liferay "intercepts" the requests and renders a login portlet on top of my home layout template in maximized window state (which is a good behavior).

My problem is that my home layout looks different from my other layout templates. So the portlet is rendered with the wrong look and feel.

Is there a way to check if the login portlet is rendered or not and if it is get the viewmode to check if I want to render my home layout or not?

This is my code for home layout checks so far. The Todo-Comment is where I'm struggeling.

<#-- 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>

Solution

  • (Answer extracted from the question)

    I just checked whether there is any portlet in maximized window state via Liferay's url params. New code:

    <#-- 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>