Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-72555

Unable to use JournalContentUtil to retrieve content for web content using embedded portlets

    Details

      Description

      Web content templates do not have access to a ThemeDisplay, but as a result of changes we made in Master, code in Liferay requires a ThemeDisplay (in order to retrieve the associated request) before tag library support is injected. While there is a ThemeDisplay available in the ServiceContext, this is also not accessible from the template.

      One approach you might consider is to make it so that anything that doesn't take in a ThemeDisplay uses a default one, but unfortunately, none of those methods are available from a web content template, because a null value must be passed for PortletRequestModel, but that results in web content templates being unable to identify which method to call because every method has an equivalent that takes in a ThemeDisplay instead of a PortletRequestModel, and Freemarker is unable to infer the correct type.

      Therefore, in addition to doing the above in order to improve consistency, we will need to add new API that is unambiguous and allows you to pass in neither a PortletRequestModel nor a ThemeDisplay.

      Steps to Reproduce

      1. Login as Test Test
      2. Open the side menu, and go to Control Panel > Configuration > System Settings
      3. Select "Web Content Administration", uncheck "Journal article force autogenerate id", and save
      4. Open the side menu, and go to Liferay DXP > Content > Web Content
      5. Click on the "..." on the top right and select Templates
      6. Add a new Freemarker template, associated with the structure "Basic Web Content", with the title EMBED_INNER and the following script:
        <@liferay_portlet["runtime"] portletName="com_liferay_hello_world_web_portlet_HelloWorldPortlet" instanceId="MAIN" queryString=""/>
        
      7. Add a new Freemarker template, associated with the structure "Basic Web Content", with the title EMBED_OUTER and the following script:
        <#assign innerContent = journalContentUtil.getContent(groupId, "EMBED_INNER", "", "", "", null, null)>
        ${innerContent}
        
      8. Click on the "<" arrow on the top of the page to navigate back to the Web Content section
      9. Add a new Basic Web Content select the EMBED_INNER template, give it the Title and ID EMBED_INNER
      10. Add a new Basic Web Content, select the EMBED_OUTER template, give it the Title and ID EMBED_OUTER
      11. Select the "Preview" button for the EMBED_OUTER article

      Steps to Test Fix

      The fix adds new API, and it can be tested by changing the EMBED_OUTER template to the following script:

      <#assign innerContent = journalContentUtil.getContent(groupId, "EMBED_INNER", "", "")>
      ${innerContent}
      

        Attachments

          Activity

            People

            Assignee:
            lu.liu Lu Liu
            Reporter:
            minhchau.dang Minhchau Dang
            Participants of an Issue:
            Recent user:
            Marta Elicegui
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              3 years, 37 weeks, 3 days ago

                Packages

                Version Package
                7.0.0 DXP FP22
                7.0.0 DXP SP4
                7.0.X EE
                7.0.4 CE GA5
                7.1.X
                Master