If file is pdf keyword modifier


(Oliver Kass) #1

I'm using a simple keyword to print related assets in a paint layout. Just wondering if there was a way to modify the following keyword for pdf files. So for example:

 

%asset_metadata_recommended.reading^as_asset:asset_name_linked%

 

Gives...

 

Standard page name linked 

 

which is ideal.

 

However for pdf files the same keyword gives:

 

pdf-name-linked.pdf

 

Was thinking there might be a way of saying "if the file name contains pdf" display %asset_attribute_title_linked% i.e.

 

Pdf name linked

 

Thanks

 

Oli


(Peter McLeod) #2

Hi Oli
Could you use a different type format in your layout, eg for a file or more specifically a pdf, then you just manually construct the link use modifiers in the same way as you have done, but with one modifier for the link up and another for the attribute title to be print on screen.

Thanks

Peter


(Oliver Kass) #3

Thanks for the reply Peter,

 

I don't think I can do it that way though as the metadata fields that are being pulled through can reference different types of asset. i.e. a related asset could be a standard page or a pdf. Ideally I need a way of using a keyword to allow for different types of asset.


(Peter McLeod) #4

Hi

 

Something like this perhaps...

<a href="%asset_metadata_recommended.reading_asset_url%">%asset_metadata_recommended.reading_asset_attribute_title^replace_keywords:empty:{asset_metadata_recommended.reading_asset_name}%</a>

However, if your related asset fields allows multiple assets then you would need to set up a listing to use instead.

 

Thanks

Peter


(Anthony Ponomarenko) #5

You could possibly use conditional keywords https://matrix-manuals.squiz.net/keyword-replacements/chapters/conditional-keywordsto print something specific for the pdf files.

 

set up a condition to check if .pdf exists in the url 

 

eg.

 

%begin_asset_metadata_recommended.reading_asset_url^contains:.pdf:1:0%
....code here.....
%end_asset%

(Oliver Kass) #6

Thanks folks. I've figured it out. This code prints the asset_attribute_title if it's a pdf or the asset_name_linked if it's any other type of asset.

 

%begin_asset_metadata_recommended.reading1^as_asset:asset_url^contains:.pdf:1:0%
  <a href="%asset_metadata_recommended.reading1^as_asset:asset_url%">
    %asset_metadata_recommended.reading1^as_asset:asset_attribute_title%
  </a>
%else_asset%
  %asset_metadata_recommended.reading1^as_asset:asset_name_linked%
%end_asset%