Aller au contenu principal

Published media filename

Commentaires

5 commentaires

  • Zendesk API User
    Author: sense - 1/30/2018 13:21

    $CMS_VALUE(pt_file.media.filename)$ gives you the filename
    $CMS_VALUE(pt_file.media.uid)$ gives you the reference name

    0
  • Zendesk API User
    Author: damon_s - 1/30/2018 17:03

    Sven,

    Thank you, that worked.

    0
  • Zendesk API User
    Author: sense - 1/31/2018 7:49

    Could you flag my answer as the correct answer please, so that everybody sees the question and the correct answer directly?

    0
  • Zendesk API User
    Author: damon_s - 1/31/2018 14:46

    Sorry, got you now.  Had the wrong post tagged by accident.

    0
  • Zendesk API User
    Author: mbergmann - 1/31/2018 15:09

    Hi,

    Using the filename or uid attribute is not a reliable solution. The reason is that the URLs of objects (pages/media files) are calculated by a separate mechanism (so called UrlFactory) of which there are multiple implementations from which you can choose in the generation tasks.

    Those implementations calculate the filenames in different ways. For example, the "Default URLs" are in deed based on the filename attribute (and the folders' uids) but the "Advanced URLs" use the display names for the URLs.

    So instead of "imitating" the concrete logic of one specific UrlFactory in the template, it is recommended to just "call" it so the filenames always match regardless of the currently used/configured UrlFactory.

    In a template, you can output the filename by using

    $CMS_VALUE(ref(pt_file).url.split("/").last)$

    This way, the ref(...).url statement will simply "call" the same mechanism that is responsible for calculating the URL, whatever it is at the moment.

    Michael

    0

Vous devez vous connecter pour laisser un commentaire.