Uploaded image for project: 'Magnolia Demo Projects'
  1. Magnolia Demo Projects
  2. MGNLDEMO-159

Links created with RichTextField within Tours content app are not resolved

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Neutral
    • 0.12
    • None
    • tours-app
    • Yes
    • Basel 41
    • 3

    Description

      If a 'Links to documents in the DAM' is included in a RichText Field in a content app, when this content is displayed as part of the page, the link is not rendered properly, the structure is like:

      ${link:{uuid:{795449d2-6c16-402e-9e8a-bbb101fe22bb},repository:{dam},path:{/tours/shark_brian_warrick_0824.JPG}}}
      

      Same case, but rich text field in a component dialog is displayed properly.

      Possible workaround: use method LinkUtil.convertLinksFromUUIDPattern()

      This issue can be reproduced in travel-demo:

      1. Edit a tour in Tour App and introduce a 'Link to a DAM Document'.
      2. Publish the content
      3. Go to publicAuthor to see the tour information, the link format is not well formed, and DAM document cannot be downloaded.

      Outcome
      ------------
      The problem is due to the tour content (in the tours workspace) coming from a model and not from the node (in this case /travel/tour in website workspace) associated with the current rendering context. This basically means that the link resolution happening at https://git.magnolia-cms.com/projects/PLATFORM/repos/main/browse/magnolia-core/src/main/java/info/magnolia/jcr/util/ContentMap.java#222 does not happen for the model, hence the unresolved link. Afaics, there's no way for the Renderer to apply the same logic to the model, because that would mean knowing the internals of the model itself (in the specific case TourDetailModel has a getTour() method returning a Tour pojo which is retrieved from the tours workspace based on some request parameter).
      All the above being said, it is the model responsibility in this case to resolve the links created with RTF component.

      An alternative could be providing a templating function like resolveLinks(String) which could be used ad hoc directly in a template script. In our case at https://git.magnolia-cms.com/projects/MODULES/repos/demo-projects/browse/community/magnolia-travel-tours/src/main/resources/tours/templates/components/tourDetail.ftl#118 e.g.

      <div class="body">${somefn.resolveLinks(tour.body)!}</div>
      

      Checklists

        Acceptance criteria

        Attachments

          Issue Links

            Activity

              People

                fgrilli Federico Grilli
                miruela Mercedes Iruela
                Votes:
                2 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  Checklists

                    Bug DoR
                    Task DoD

                    Time Tracking

                      Estimated:
                      Original Estimate - Not Specified
                      Not Specified
                      Remaining:
                      Remaining Estimate - 0d
                      0d
                      Logged:
                      Time Spent - 1.5d
                      1.5d