Search code examples
liferayfreemarkermeta-tagsliferay-7

How to retrieve data from portlet to portal_normal.flt - Liferay


I want to retrieve some data from my custom portlet and put it to meta tags in portal_normal.ftl . I've tried this:

<#if (renderRequest.getAttribute("something"))??>
            <#assign urlImg = renderRequest.getAttribute("something")/>
        <#else>
            <#assign urlImg = "defaultturl"/>
        </#if>

, but i always get null. Probably my portlet is loaded after theme and it will never acces this data. Have you any idea how to solve it? Thanks!


Solution

  • It is not common that a custom Portlet will provide data for the theme. Also, I am not sure if it will be the same Request object in the theme as in your Portlet, because some request related objects (session etc.) are usually scope to the Portlet (unshared).

    You should rather use a Theme Context Contributor as descripted on this Liferay tutorial: DXP context-contributors. When using TYPE_THEME and implementing the interface, you can add data to your theme template.