Document type link formatting in content

(Ian Hirst) #1

Matrix Version:
When a content editor adds a link to a document within some content on a page, we’d like it to display a linked name to the document, the file type (e.g. PDF) and the file size (e.g. 2mb).
We have created a paint layout that does this:

<div class="doc-row">
  <div class="doc-title"><a href="%asset_url%">%asset_attribute_title%</a></div>
  <div class="doc-info">%asset_type^maxwords:1% %asset_file_size_readable%</div>

Then we use global keywords in the content to apply this paint layout to the document we’re linking to:


and with the CSS applied it looks like this:

All well and good, but we wondered if there’s either a) a different way to do this or b) a way of adding the global keyword to the list of matrix keywords available in the WYSIWYG editor so that content editors can simply select it, then add the asset number of the file they want to reference.

(Tbaatar) #2

You could probably achieve this using the Metadata Related Asset Type.

When a new page is created all related documents, files and pages can be linked via the Metadata Related Asset, and use paint layout to print result either with Asset Listing or SSJS.

The Metadata Related Asset field is exposed to your editors and you can restrict asset type and root node so that files or documents can be found easily.

(Hugh McMaster) #3

Have you looked at the File Summary Format in Global Preferences?

Editors can simply toggle on the summary option when adding a hyperlink to a file. So, with HTML set in Global Preferences and CSS loaded on the system you should be able to do the same thing far more easily.

For example,
%file_type^uppercase%, %asset_file_size_in_bytes^divide:1024^round:2% KB
will generate DOCX, 30.64 KB. On my system, I’m styling the output in brackets and with small text, so it’s not visually intrusive.

(Ian Hirst) #4

Thanks - we’re using related asset metadata to display a ‘Documents’ section at the bottom of the page and that’s displaying fine. The use case we’re trying to address is when an editor wants to link to a file within the body of the content.

(Ian Hirst) #5

Thanks mhcmaster, we will look at using this.