3

Is there a possibility to include file metadata fields to the anchor's markup in RTF?

On our custom Rich Text Field class, we want to access image and file metadata fields to extend functionalities for those anchor fields.

When the editors add an anchor to this file to an RTF field, we would like to extend this functionality and provide custom HTML Markup based on that metadata field.

We're using SDL Web 8.5, and Java DXA 1.7

Currently this is the information we have on the RTF's souce:

<a href="tcm:7-417850" title="AGA Offshore Manifold datasheet.pdf">PDF 1</a>

Once it reaches to our custom RichTextField class we also have file information, such as xlin:href, data-schemauri, data-multimediafilename, etc.

And need the metadata fields included to the anchor attributes

1 Answer 1

1

DXA 1.x uses a TBB called “Resolve Rich Text” to preprocess Rich Text Fields. This is the TBB that puts the data- attributes on a and ing elements which are referencing Multimedia Components. It has a parameter called multimediaLinkAttributes which allows you to specify the names of (Multimedia Component) metadata fields to include as data- attrubutes in the HTML.

See: https://github.com/sdl/dxa-content-management/blob/release/1.7/Sdl.Web.Tridion.Templates/Templates/ResolveRichText.cs

UPDATE:

The "Resolve Rich Text" TBB is invoked from the "Default Page Template Finish Actions" and "Default Component Template Finish Actions" TBBs. That is where the parameter values are passed in. For example:

<CompoundTemplate xmlns="http://www.tridion.com/ContentManager/5.3/CompoundTemplate">
  <TemplateInvocation>
    <Template xlink:href="tcm:2-49-2048" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:title="Resolve Rich Text" />
    <TemplateParameters>
      <Parameters xmlns="http://www.sdl.com/web/schemas/resolverichtext">
        <multimediaLinkAttributes xmlns="http://www.sdl.com/web/schemas/resolverichtext">youTubeId, headline, playerType, customVideoAutoplay, customVideoSubtitles, customVideoControls</multimediaLinkAttributes>
      </Parameters>
    </TemplateParameters>
  </TemplateInvocation>
</CompoundTemplate>
2
  • Hi Rick, this sounds like it is the solution we're looking for. Though for the time being I've tried to add those multimediaLinkAttributes to the TBB (maybe wrong approach), to which I got a notification that the multimediaLinkAttributes was not a valid parameter when saving. Could you provide some guidance on how or where this parameter should be added? Mar 26, 2018 at 7:58
  • I have added some text to the Answer to explain where/how to set the parameter value. Mar 26, 2018 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.