<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Liferay7 WebContent template: retrieve document title (FTL)</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=94079268" />
  <subtitle>Liferay7 WebContent template: retrieve document title (FTL)</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=94079268</id>
  <updated>2026-04-15T21:52:53Z</updated>
  <dc:date>2026-04-15T21:52:53Z</dc:date>
  <entry>
    <title>RE: Liferay7 WebContent template: retrieve document title (FTL)</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=94167167" />
    <author>
      <name>Thomas Kellerer</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=94167167</id>
    <updated>2017-08-29T05:32:34Z</updated>
    <published>2017-08-29T05:32:34Z</published>
    <summary type="html">Thanks, that worked.</summary>
    <dc:creator>Thomas Kellerer</dc:creator>
    <dc:date>2017-08-29T05:32:34Z</dc:date>
  </entry>
  <entry>
    <title>RE: Liferay7 WebContent template: retrieve document title (FTL)</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=94086720" />
    <author>
      <name>Massimo Bevilacqua</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=94086720</id>
    <updated>2017-08-28T07:58:18Z</updated>
    <published>2017-08-28T07:58:18Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi Thomas,&lt;br&gt;&lt;br&gt;I don't know if there is a better way to do it, but one solution could be this:&lt;br&gt;&lt;br&gt;the ${media.getData()} is stored in this way &lt;br&gt;&lt;pre&gt;&lt;code&gt;/documents/[doc-group-id]/0/[doc-title]/[doc-uuid]&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;So you can retrieve  file using Group id and uuid and then you will have all the file information&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;
&amp;amp;lt;#assign counter = 0 &amp;amp;gt;
&amp;amp;lt;#list "${media.getData()}"?split("/") as x&amp;amp;gt;
&amp;amp;lt;#if counter == 2&amp;amp;gt;
&amp;amp;lt;#assign groupId = x?number &amp;amp;gt;
&amp;lt;!--#if--&amp;gt;
&amp;amp;lt;#if counter == 5&amp;amp;gt;
&amp;amp;lt;#assign uuId = x &amp;amp;gt;
&amp;lt;!--#if--&amp;gt;
&amp;amp;lt;#assign counter = counter+1 &amp;amp;gt;
&amp;lt;!--#list--&amp;gt;

&amp;amp;lt;#assign dlFileEntryService = serviceLocator.findService('com.liferay.document.library.kernel.service.DLFileEntryService') /&amp;amp;gt; 

&amp;amp;lt;#assign file = dlFileEntryService.getFileEntryByUuidAndGroupId(uuId,groupId)  &amp;amp;gt;
&amp;lt;h1&amp;gt;${file.fileName}&amp;lt;/h1&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;In order to use ServiceLocator you need to add these lines to your portal-ext.properties&lt;br&gt;&lt;pre&gt;&lt;code&gt;
freemarker.engine.restricted.classes=
freemarker.engine.restricted.packages=
freemarker.engine.restricted.variables=
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;or you can delete these values from:&lt;br&gt;Control panel -&amp;gt; Configuration -&amp;gt; System setting -&amp;gt;Foundation -&amp;gt; Freemarker engine&lt;br&gt;&lt;br&gt;A server start is required&lt;br&gt;&lt;br&gt;If you want you can just take the doc-title name from &lt;br&gt;&lt;pre&gt;&lt;code&gt;/documents/[doc-group-id]/0/[doc-title]/[doc-uuid]&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;in this way&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;amp;lt;#if counter == 4&amp;amp;gt;
&amp;amp;lt;#assign name = x &amp;amp;gt;
&amp;lt;!--#if--&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;but in this way if the file name has a space inside, Liferay adds a "+", my file.mp3 become my+file.mp3&lt;br&gt;Maybe in the future you will need others information so I think it is better to retrive the file instead only the name&lt;br&gt;Hope it helps&lt;br&gt;&lt;br&gt;Massimo&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Massimo Bevilacqua</dc:creator>
    <dc:date>2017-08-28T07:58:18Z</dc:date>
  </entry>
  <entry>
    <title>Liferay7 WebContent template: retrieve document title (FTL)</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=94079267" />
    <author>
      <name>Thomas Kellerer</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=94079267</id>
    <updated>2017-08-28T06:34:49Z</updated>
    <published>2017-08-28T06:34:49Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;I have a WebContent structure with a "Documents &amp;amp; Media" field.&lt;br&gt;&lt;br&gt;I finally figured out that the download URL is no available through getUrl() or getFriendlyUrl() but strangely enough through getData().&lt;br&gt;&lt;br&gt;However I can't find a way to get the &lt;strong&gt;name&lt;/strong&gt; of the document in FreeMarker.&lt;br&gt;&lt;br&gt;The code generated by the template editor:&lt;pre&gt;&lt;code&gt; ${languageUtil.format(locale, "download-x", "Dokument")})&lt;/code&gt;&lt;/pre&gt;is pretty much useless as it displays a constant label, not the name of the document. &lt;br&gt;&lt;br&gt;Neither getTitle() nor getTitle(locale) work (as TemplateNode does not have those methods). getName() only returns the name of the field, not the name of the document. The "attributes" map only contains the language-id &lt;br&gt;&lt;br&gt;So how can I display the (localized) &lt;strong&gt;name&lt;/strong&gt; of the document? &lt;br&gt;&lt;br&gt;Surely I am not the first one to try something so obvious.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Thomas Kellerer</dc:creator>
    <dc:date>2017-08-28T06:34:49Z</dc:date>
  </entry>
</feed>
