Search code examples
liferayfreemarkerliferay-themeliferay-7

set web content default preferences of portlet freemarker and liferay 7


I read that I can set a default content to display in a portlet into the theme layout, with this code:

<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone") />
<#assign VOID = freeMarkerPortletPreferences.setValue("groupId", "37295") />
<#assign VOID = freeMarkerPortletPreferences.setValue("articleId", "46616") />

<@liferay_portlet["runtime"]
    defaultPreferences="${freeMarkerPortletPreferences}"
    instanceId="quick_links" 
portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet"/>

but when I did this, the portlet display that I need set a web content to display:

select web content

I have hardcode the groupId because the web content that I want display was created on another site.


Solution

  • I think you have a typo... check this example (https://dev.liferay.com/pt/develop/tutorials/-/knowledge_base/7-0/applying-portlet-decorators-to-embedded-portlets)

    <#assign VOID =
    freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId",
    "barebone")>
    
    <div aria-expanded="false" class="collapse navbar-collapse"
    id="navigationCollapse">
        <#if has_navigation && is_setup_complete>
            <nav class="${nav_css_class} site-navigation"
            id="navigation" role="navigation">
               <div class="navbar-form navbar-right" role="search">
                 <@liferay.search default_preferences=
                 "${freeMarkerPortletPreferences}" />
               </div>
    
               <div class="navbar-right">
                 <@liferay.navigation_menu default_preferences=
                 "${freeMarkerPortletPreferences}" />
               </div>
            </nav>
        </#if>
    </div>
    
    <#assign VOID = freeMarkerPortletPreferences.reset()>