Legacy Knowledge Base
Published Jun. 30, 2025

How Can I Identify Which Widget Templates Are in Use?

Written By

Emma Carr-Gardner

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

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.


  • 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

 

 

Did this article resolve your issue ?

Legacy Knowledge Base