Issue
- How can I know which of my Widget Templates are in use?
- How can I see where my Widget Templates are being used throughout the Liferay instance?
Environment
- Liferay DXP
Resolution
- For users on Liferay DXP 7.4, you can use the UI to find which of your Templates are in use, and where they are being used.
- Navigate to Product Menu > Design > Templates > Widget Templates
- Here you can see the number of usages, and clicking the more actions button, and you can view the usages for that template.
-
- Navigate to Product Menu > Design > Templates > Widget Templates
- For users on Liferay DXP 7.0-7.3, you can use a groovy script (attached here).
- Navigate to Control Panel > Server Administration > Script and pasted the attached script.
-
List<com.liferay.portal.kernel.model.PortletPreferences> portletPreferences = com.liferay.portal.kernel.service.PortletPreferencesLocalServiceUtil.getPortletPreferences();
for (com.liferay.portal.kernel.model.PortletPreferences portletPreference : portletPreferences) {
String preferencesXML = portletPreference.getPreferences();
javax.portlet.PortletPreferences jxPortletPreferences = com.liferay.portal.kernel.portlet.PortletPreferencesFactoryUtil.fromDefaultXML(preferencesXML);
String displayStyle = jxPortletPreferences.getValue("displayStyle", "");
if (displayStyle.isEmpty()) {
continue;
}
com.liferay.portal.kernel.model.Layout layout = com.liferay.portal.kernel.service.LayoutLocalServiceUtil.fetchLayout(portletPreference.getPlid());
out.println( "Template Name: " + displayStyle);
out.println( "Layout Name: " + layout.getNameCurrentValue() + " Plid: " + portletPreference.getPlid());
out.println( "PortletId: " + portletPreference.getPortletId());
out.println( "----");
}
Additional Information