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

Asset Publisher fails to display content when sorted or filtered by a Web Content field when the user has switched to another language

    Details

    • Fix Priority:
      3

      Description

      (This was first observed on sales.liferay.com - 7.2, and on our in-progress upgrade to 7.3 on our dev environment - please let me know if you would like access to review.  I've now replicated on a clean 7.3 bundle)

      When using Asset Publisher to dynamically display lists of Web Content articles, if a user switches their language to anything other than the system default, Asset Publisher fails to return the correct results and sorts incorrectly in the following two scenarios:

      1. When filtering is based on a Web Content structure field, no matching articles are found
      2. When sorting is based on a Web Content structure field results are not sorted by this field.  A sort order is applied, but the results are inconclusive - if the sort is based on "Title" or "Created Date" then it appears to be correct, but if the sort is based on "Modified Date" it is still incorrect

      Steps to reproduce:

      Create a Web Content Structure with a "Select" field, assign multiple values:

      • Web Content Structure: "Sort Test"
      • Field: "SortField"
      • Field values: "A" ,"B", "C", "D", "E"

      Create a Category Vocabulary, assigned to "Sort Test" web content structure:

      • Vocabulary name "Filter Test"
      • Categories: "A", "B", "C", "D"

      Add a number of Web Content Articles with different field values and categories

      I created 10 with Titles as follows (Field value and Category match the title):

      • Title 1 - Cat D - Field A
      • Title 2 - Cat D - Field A
      • Title 3 - Cat D - Field A
      • Title 4 - Cat D - Field D
      • Title 5 - Cat D - Field D
      • Title 6 - Cat D - Field E
      • Title 7 - Cat D - Field C
      • Title 8 - Cat C - Field A
      • Title 9 - Cat C - Field A
      • Title 10 - Cat D - Field B

      This can be tested with default Widget Templates, but it is easier to see the results with a custom template to display just the title, and a slightly more complex one to display the Field value

      Widget Template to display Web Content Title ("Title"):

      <#if entries?has_content>
         <#list entries as entry>
               ${entry.getTitle(locale)}<br>
         </#list>
      </#if>

      Widget Template to display Web Content Field ("Sort Field"):

      <#if entries?has_content>
         <#list entries as entry>
           <#assign assetRenderer = entry.getAssetRenderer() />
           <#assign className = assetRenderer.getClassName() />
           <#assign journalArticle = assetRenderer.getArticle() />
           <#assign document = saxReaderUtil.read(journalArticle.getContent()) />  
           <#assign rootElement = document.getRootElement() />
           <#assign xPathSelector = saxReaderUtil.createXPath("dynamic-element[@name='SortField']") />
           <#assign currentValue = xPathSelector.selectSingleNode(rootElement).getStringValue() />
           ${currentValue}, ${entry.getTitle(locale)}<br>
         </#list>
       </#if>

      Create three pages, each with two Asset Publishers, one to test Filtering, the other to test sorting.

      Page 1 - this is a "control" that will display all 10 Web Content Articles:

      Asset Publisher 1:

      • Asset Type: "Web Content Article"
      • Web Content Article Structure: "Sort Test"
      • Order by "Title" (Ascending)
      • Display Template: "Title"

      Asset Publisher 2:

      • Asset Type: "Web Content Article"
      • Web Content Article Structure: "Sort Test"
      • Order by "Section" (Ascending)
      • Display Template: "Sort Field"

      Page 2 - Both Asset Publishers filtered by Category "D":

      Asset Publisher 1:

      • Asset Type: "Web Content Article"
      • Web Content Article Structure: "Sort Test"
      • Filter by Category "D"
      • Order by "Title" (Ascending)
      • Display Template: "Title"

      Asset Publisher 2:

      • Asset Type: "Web Content Article"
      • Web Content Article Structure: "Sort Test"
      • Order by "Section" (Ascending)
      • Filter by Category "D"
      • Display Template: "Sort Field"

      Page 3 - Asset Publisher 1 filtered by field "SortTest" with value "A" and Category "D":

      Asset Publisher 1:

      • Asset Type: "Web Content Article"
      • Web Content Article Structure: "Sort Test"
      • Filter by Field: "Yes"
      • Field to filter on: "SortField"
      • Field value: "A"
      • Filter by Category "D"
      • Order by "Title" (Ascending)
      • Display Template: "Title"

      Asset Publisher 2 (identical to page 2):

      • Asset Type: "Web Content Article"
      • Web Content Article Structure: "Sort Test"
      • Order by "Section" (Ascending)
      • Filter by Category "D"
      • Display Template: "Sort Field"

      Results - Default Language "English (United States)":

      Page 1

      • Asset Publisher 1 shows 10 records, in title order (Title 1, Title 10, Title 2 etc.)
      • Asset Publisher 2 shows 10 records, in field value order ("A, Title 1...", "A, Title 2...", "A, Title 3..." etc.)

      Page 2

      • Asset Publisher 1 shows 8 records in title order - just those with Category "D"
      • Asset Publisher 2 shows 10 records - identical to page 1

      Page 3

      • Asset Publisher 1 shows 3 records (Title 1, Title 2 and Title 3)
      • Asset Publisher 2 shows 10 records - identical to pages 1 and 2

      Results - Switch user language to "français":

      (Click User Icon, choose Account Settings, Language, select "français")

      Page 1

      • Asset Publisher 1 shows 10 records, in title order (Title 1, Title 10, Title 2 etc.)
      • Asset Publisher 2 shows 10 records, but not in field value order.  Order will depend on secondary sort on AP - e.g. if secondary sort is in Title order then results will be in Title order

      Page 2

      • Asset Publisher 1 shows 8 records in title order - just those with Category "D"
      • Asset Publisher 2 shows 10 records - identical to page 1

      Page 3

      • Asset Publisher 1 shows 0 records 
      • Asset Publisher 2 shows 10 records - identical to pages 1 and 2

      Note - it is not strictly necessary to follow all of these steps to reproduce - I created more articles and more pages than strictly necessary to apply some "control" to narrow in on the problem.  A single page (Page 3) could be used, with a smaller number of content articles.

        Attachments

          Activity

            People

            Assignee:
            support-lep@liferay.com SE Support
            Reporter:
            benjamin.turner Benjamin Turner
            Participants of an Issue:
            Recent user:
            Yang Cao
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Days since last comment:
              8 weeks ago

                Packages

                Version Package