'Configuring Asset Publisher via FreeMarker in WebContent Template

I am able to add an asset publisher portlet in the web content template by

<@liferay_portlet["runtime"]
defaultPreferences="${freeMarkerPortletPreferences}"
portletProviderAction=portletProviderAction.VIEW
portletProviderClassName="com.liferay.asset.kernel.model.AssetEntry"/>

However, I will want to filter the contents shown in asset publisher base. From the Liferay console, it will be similar to the screenshow below. How can I do this programatically in the web content template? Liferay console to configure the contents

I have tried codes like the below to modify the preferences, but they are not taking effect.

<#assign VOID = freeMarkerPortletPreferences.setValue("selectionStyle", "manual")>


Solution 1:[1]

5 years after... but I was struggling with this today so I left here an example for the future:

<#assign defaultPreferencesValues = freeMarkerPortletPreferences.getPreferences({
        "displayStyle": "ddmTemplate_1661082",
        "classNameIds": "20109",
        "classTypeIds":["98680","1760136"],
        "classTypeIdsJournalArticleAssetRendererFactory":"98680,1760136"
    }) />


    <@liferay_portlet["runtime"]
        instanceId="xxxlove"
        defaultPreferences=defaultPreferencesValues
        portletProviderAction=portletProviderAction.VIEW
        portletProviderClassName="com.liferay.asset.kernel.model.AssetEntry"
    />

To find out which are those preferences you can configure an asset publisher in a page, get its instance id and look its preferences in database

select * from portletpreferencevalue where portletpreferencesid in (select portletpreferencesid from portletpreferences where portletid like 'com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet_INSTANCE_8sDabfIMRUKu');

Tested in Liferay 7.4.3.20

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1