liferayweb-content

Get portlet/page containing web content in Liferay


I'm trying to make the Liferay (6.0.6) Asset Publisher publish all changes across multiple communities on the portal homepage. By clicking on a link the user is supposed to be redirected to another community and see the new web content. The problem is that the default behaviour of asset publisher (even with the hook to gather info from all communities) tries to get the url by searching the group of the current page (in which the content is not). I decided to change the jsp showing the page to search all pages across all communities and find the first one containing the portlet with the desired web content. So

  1. How could I get the portlet containing the web content by journal id of the web content?
  2. How could I get the page containing the portlet?

Thanks


Solution

  • The PortletPreferences table in the database contains the configurations of each portlet in the system. The configuration of an articleId for a Web Content Display portlet is stored as a preference in this table. If you look at that table, there are 3 important columns:

    An example of the preferences XML:

    <portlet-preferences>
        <preference><name>group-id</name><value>10139</value></preference>
        <preference><name>article-id</name><value>14295</value></preference>
    </portlet-preferences>
    

    So it's just a question of getting your SQL queries right. As far as I know, there is no service you can call directly for this.

    SELECT l.friendlyURL
    FROM PortletPreferences p, Layout l
    WHERE p.plid=l.plid 
    AND p.portletid LIKE '56_INSTANCE_%' 
    AND p.preferences LIKE '<preference><name>article-id</name><value>14295</value></preference>';