Search code examples
javascriptjqueryliferayliferay-6

Check Liferay Version from Browser


Is there a way to find out which version of Liferay is deployed on the Server from the Browser through Javascript/jQuery or the Source Code?

I have looked at Liferay's Javascript API. It consists of many helpful methods.

Liferay Javascript API Liferay Javascript API Liferay Javascript API

Is there a method in the API that I can use to find out which Liferay Version the loaded page is running on?

Edit: Or is there any other way like checking a loaded resource (js/images/css/source/theme) name from the client-end to confirm that the portal runs on a specific liferay version? Any crude suggestions are welcome.


Solution

  • A couple crude suggestions:

    1. you could check the server administration page in the control panel.

    2. digging into the source for that page, I found that the static Java class com.liferay.portal.kernel.util.ReleaseInfo has all the information regarding the liferay version.

    To my knowledge, this information is not readily accessible on publicly available client side, but you can make it so, for instance by inserting the following in your JSP :

      <aui:script>
          Liferay.version = "<%=HtmlUtil.escapeJS(com.liferay.portal.kernel.util.ReleaseInfo.getReleaseInfo()) %>"
      </aui:script>
    

    EDIT: Liferay does include the build number in its static resource urls as the parameter b. for instance, in the following extract from the liferay.com home page :

    <link href="[...]/main.css?[...]b=6120&amp;t=1382040996000" rel="stylesheet" type="text/css" />
    

    the parameter b=6120 gives the build number of the portal. It is set in PortalImpl.java:

    @Override
    public String getStaticResourceURL(
        HttpServletRequest request, String uri, String queryString,
        long timestamp) {
    
          [...]
    
        // Build number
    
        sb.append("&b=");
        sb.append(ReleaseInfo.getBuildNumber());
    
          [...]
    

    Hope this helps,

    Alain