RE: Get unique ID of the asset publisher

Jamie Sammons, modified 1 Year ago. New Member Posts: 3 Join Date: 9/5/22 Recent Posts

I have 3 asset publisher inside a page, and I have to manage some javascript interaction.

In my freemarker widget template I need a unique ID to use in my js in order to know exactly which of the 3 asset publisher I am controlling, as you can do with fragments.

How can I print it out?

thumbnail
Jamie Sammons, modified 1 Year ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts

Hi,

You can use the portlet instance id for referring each asset publisher on the page.

${themeDisplay.getPortletDisplay().getId()}

or

${themeDisplay.getPortletDisplay().getInstanceId()}

 

Jamie Sammons, modified 1 Year ago. New Member Posts: 3 Join Date: 9/5/22 Recent Posts

Thank you,

This is how I used it, for the sake of readability

<#assign portlet_id = themeDisplay.getPortletDisplay().getId() />
<#assign split_id = portlet_id?split("_") />
<#assign el_id = split_id?last />

${el_id}