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

Related Asset Publisher portlet's Back button does not function when using a custom display template

    Details

      Description

      Description
      Related Asset Publisher portlet's Back button does not function when using a custom display template

      Steps to reproduce/Testing done

      1. Start Liferay
      2. Login as administrator
      3. Go to Site Administration > Content > Web Content > Manage > Structures
      4. Create a structure named "MyStruct" with an HTML field named, "MyHTML"
      5. Go to Site Administration > Content > Web Content > Manage > Templates
      6. Create a template named, "MyStructTemplate" with "MyStruct" as the structure, and add the following to the script:
        ${MyHTML.getData()}
        
      7. Create the following articles using MyStruct:
        1. Title: One, MyHTML: The first
        2. Title: Two, MyHTML: The second, Related Assets: One
        3. Title: Three, MyHTML: The third, Related Assets: One
      8. Add a page named, "BackTest"
      9. Add an Asset Publisher and Related Asset portlet to the page
      10. Go to Related Asset portlet > Configuration > Display Settings > Manage Display Templates for Liferay
      11. Add a new Asset Publisher Template named, "MyStructTemplate_List" with the following script:
        <#if entries?has_content>
         <ul>
             <#list entries as entry>
             <li>
                 <#assign assetRenderer = entry.getAssetRenderer() />
                 <#assign viewURL = assetPublisherHelper.getAssetViewURL(renderRequest, renderResponse, entry) />
                 <#if assetLinkBehavior != "showFullContent">
                     <#assign viewURL = assetRenderer.getURLViewInContext(renderRequest, renderResponse, viewURL) />
                 </#if>
                <a href="${viewURL}"><b>${entry.getTitle(locale)}</b></a>:
                <#assign docXml = saxReaderUtil.read(assetRenderer.getArticle().getContent()) />
                <#assign fld_MyHTML = docXml.valueOf("//dynamic-element[@name='MyHTML']/dynamic-content/text()") />
                ${fld_MyHTML}<br />
            </li>
            </#list>
            </ul>
        <#else>
            This structure has no related information.
        </#if>
        <br />
        
      12. Go to Related Asset portlet > Configuration > Display Settings
      13. Select under Display Template, MyStructTemplate_List and save
      14. Go to BackTest
      15. Click on One in the Asset Publisher
      16. Notice that articles Two and Three show up in the Related Assets portlet
      17. Click on Two in the Related Assets portlet
      18. Notice that Article Two now displays in the Related Assets Portlet
      19. Click the back button in the Related Assets portlet
      20. Notice that the page renders, but the Related Assets portlet still displays Article Two

      In my testing with and without the custom Asset Publisher Template, I discovered that the Back button link is formed differently:

      Custom Asset Publisher Display Template Back button link:

      <a class="icon-circle-arrow-left previous-level" href="/web/guest/backtest/-/asset_publisher/mIJBQMZLPO9x/content/one?_101_INSTANCE_mIJBQMZLPO9x_redirect=http%3A%2F%2Flocalhost%3A8080%2Fweb%2Fguest%2Fbacktest%3Fp_p_id%3D101_INSTANCE_mIJBQMZLPO9x%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_count%3D1&amp;redirect=http%3A%2F%2Flocalhost%3A8080%2Fweb%2Fguest%2Fbacktest%3Fp_p_id%3D101_INSTANCE_mIJBQMZLPO9x%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_count%3D1" id="_175_INSTANCE_hHNLyrNWeETI_TabsBack" title="Back"> <span class="helper-hidden-accessible"> Back </span> </a>
      

      Without Custom Asset Publisher Display Template Back button link:

      <a class="icon-circle-arrow-left previous-level" href="http://localhost:8080/web/guest/test-page-1?p_p_id=175_INSTANCE_HhjTagysvuxI&amp;p_p_lifecycle=0&amp;p_p_state=normal&amp;p_p_mode=view&amp;p_p_col_id=column-1&amp;p_p_col_count=1&amp;_175_INSTANCE_HhjTagysvuxI_struts_action=%2F175%2Fview" id="_175_INSTANCE_HhjTagysvuxI_TabsBack" title="Back"> <span class="helper-hidden-accessible"> Back </span> </a>
      

      Results of Testing
      Expected behavior: The Back button takes the user back to the list in Related Assets
      Actual behavior: The Back button renders the page again, but does not render the list in the Related Assets

      Errors/Logs
      No errors or logs are generated

      Reproduced...
      Reproduced in trunk? Yes (a6cd753a7edb6b21e92e6c76a668636265c1135d)
      Reproduced in 6.2.x? Yes (0145163190dfe8ac61034aba561da784c7403221)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  5 years, 28 weeks, 1 day ago

                  Packages

                  Version Package
                  6.2.3 CE GA4
                  6.2.X EE
                  7.0.0 M1