How to pass an array of categories to an embedded Asset Publisher?
Written By
Alfonso Crisci
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Issue
- How to pass an array of categories to an embedded Asset Publisher?
Resolution
- In 7.0, you can place something like this in the portal_normal.ftl of your custom theme:
<#assign VOID = freeMarkerPortletPreferences.setValue("queryValues0",["assetCategory1.getCategoryId()","assetCategory2.getCategoryId()"]
<@liferay_portlet["runtime"]
defaultPreferences="${freeMarkerPortletPreferences}"
instanceId="MyID1234"
portletProviderAction=portletProvideAction.VIEW
portletName="com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet"
/>
- In 7.1+,
setValue was deprecated, therefore, to achieve the same result, make sure you have the fix for LPS-109837 installed and use a Freemarker code similar to the below:
<#assign prefs = {
"queryContains0":"true",
"queryAndOperator0":"false",
"queryName0":"assetCategories",
"queryValues0": ["assetCategory1.Id","assetCategory2.Id"]
} />
<@liferay_portlet["runtime"]
defaultPreferences = freeMarkerPortletPreferences.getPreferences(prefs)
instanceId="coolInstanceId7777"
portletProviderAction=portletProviderAction.VIEW
portletName="com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet"
/>
where the values for queryValues0 are taken from DB AssetCategory.categoryid 's column
Did this article resolve your issue ?