<?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>How to link to a page with Document and Media Portlet with variable folder</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=113138529" />
  <subtitle>How to link to a page with Document and Media Portlet with variable folder</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=113138529</id>
  <updated>2026-04-05T03:39:47Z</updated>
  <dc:date>2026-04-05T03:39:47Z</dc:date>
  <entry>
    <title>RE: How to link to a page with Document and Media Portlet with variable fol</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113191097" />
    <author>
      <name>Andrew Jardine</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113191097</id>
    <updated>2019-04-12T13:58:38Z</updated>
    <published>2019-04-12T13:58:38Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;You can, or you can make sure that you have access to the "liferay-portlet-url" and then you can use the JS objects that Liferay provides.&amp;nbsp;&lt;br&gt;&lt;br&gt;Liferay. It will allow you to create a render, action or resource url in js and set the parameters dynamically.&amp;nbsp;&lt;pre&gt;&lt;code&gt;var renderURL = Liferay.PortletURL.createRenderURL();
var actionURL = Liferay.PortletURL.createActionURL();
var resourceURL = Liferay.PortletURL.createResourceURL();

// set url properties here

String url = renderURL.toString();
window.location = url;
&lt;/code&gt;&lt;/pre&gt;One thing to note though, friendly urls won't be applied here because the URLs are generated client side in the browser. For the crazy long portlet url to be converted into something a little leaner (like /-/document...) version, it needs to be crafted server side.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Andrew Jardine</dc:creator>
    <dc:date>2019-04-12T13:58:38Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to link to a page with Document and Media Portlet with variable fol</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113185733" />
    <author>
      <name>Francisco Aires</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113185733</id>
    <updated>2019-04-12T10:41:28Z</updated>
    <published>2019-04-12T10:41:28Z</published>
    <summary type="html">&lt;span style="font-family: Arial, Helvetica, sans-serif"&gt;I&amp;#39;m using one JSP that display a table empty.&lt;br /&gt;&lt;br /&gt;Therefore i use a javascript function calling a service to get the customeres and populate my table.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        function display(portletnamespace){&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            Liferay.Service(&lt;br /&gt;                          &amp;#39;/patient.patient/get-customers&amp;#39;,&lt;br /&gt;                          {&lt;br /&gt;                                start: 0,&lt;br /&gt;                                end: 20,&lt;br /&gt;                         },&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                function(result){&lt;br /&gt;                &lt;br /&gt;                var table= [];&lt;br /&gt;            &lt;br /&gt;                &lt;br /&gt;                for(i=0;i&amp;lt;20;i++) {&lt;br /&gt;    &lt;br /&gt;                var customerFolderId=result&lt;em&gt;.customerFolderId;&lt;br /&gt;&lt;br /&gt;                    table.push(&amp;#39;&amp;amp;nbsp;&amp;lt;a class=&amp;#34;btn btn-primary&amp;#34; href=&amp;#39;PathForDocuments+&amp;#34;/-/document_library/view&amp;#34;+&amp;#34;&amp;amp;&amp;#34;+portletnamespace+&amp;#34;folderId=&amp;#34;+customerFolderId&amp;#39;&amp;gt;&lt;br /&gt;&lt;br /&gt;                             &amp;lt;span class=&amp;#34;glyphicon glyphicon-download-alt&amp;#34;&amp;gt;&amp;lt;/span&amp;gt;Documents&amp;lt;/a&amp;gt;&amp;#39;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                    $(&amp;#34;#customer&amp;#34;).html(table.join(&amp;#39;&amp;#39;));&lt;br /&gt;                }&lt;br /&gt;            });&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;    I need to create the PathForDocuments in the href . Maybe create a PortletURL in the portlet and pass it to the display ?&lt;br /&gt;    &lt;br /&gt;    Thank you for following up &lt;/em&gt;&lt;/span&gt;</summary>
    <dc:creator>Francisco Aires</dc:creator>
    <dc:date>2019-04-12T10:41:28Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to link to a page with Document and Media Portlet with variable fol</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113162060" />
    <author>
      <name>Andrew Jardine</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113162060</id>
    <updated>2019-04-11T15:30:28Z</updated>
    <published>2019-04-11T15:30:28Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;OK! So now I understand what you are trying to do. The authtoken isn't realy applicable for your case because those are normally used for ActionURLs. You want to render the contents of a folder so yo ushoul dbe using a RenderURL. The url you see that Liferay provides is /-/documents or whatever that is the result of a render url that is altered based on a friendlyURL mapping configuration. You can easily identify these because they gave the /-/ separator. So what you want is to generate the appropriate RenderURL .. Liferay does it like this (in a JSP)&lt;pre&gt;&lt;code&gt;PortletURL portletURL = liferayPortletResponse.createRenderURL();

portletURL.setParameter("mvcRenderCommandName", (folderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) ? "/document_library/view" : "/document_library/view_folder");
portletURL.setParameter("navigation", navigation);
portletURL.setParameter("curFolder", currentFolder);
portletURL.setParameter("deltaFolder", deltaFolder);
portletURL.setParameter("folderId", String.valueOf(folderId));&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;... so now my next two questions are.&lt;br&gt;&lt;br&gt;1. Do you have a JSP you can use? or do you have to render it in Javascript?&lt;br&gt;&lt;br&gt;2. Are you able to share any of your code with us?&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Andrew Jardine</dc:creator>
    <dc:date>2019-04-11T15:30:28Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to link to a page with Document and Media Portlet with variable fol</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113161716" />
    <author>
      <name>Andrew Jardine</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113161716</id>
    <updated>2019-04-11T15:27:46Z</updated>
    <published>2019-04-11T15:27:46Z</published>
    <summary type="html">I&amp;#39;ve answered this now 3 times and my reply keeps getting lost. If this works, I&amp;#39;ll try once more.</summary>
    <dc:creator>Andrew Jardine</dc:creator>
    <dc:date>2019-04-11T15:27:46Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to link to a page with Document and Media Portlet with variable fol</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113150829" />
    <author>
      <name>Francisco Aires</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113150829</id>
    <updated>2019-04-11T14:11:35Z</updated>
    <published>2019-04-11T14:11:35Z</published>
    <summary type="html">Just to clarify, maybe i didn&amp;#39;t make myself clear &lt;br /&gt; &lt;br /&gt;I have a custom Portlet but i also use the OOTB D&amp;amp;M porlet. I need to control what the folder OOTB D&amp;amp;M portlet shows with some url parameter &lt;br /&gt;&lt;br /&gt;My point is to create a button with href (by parameterize the url  that point to the portlet D&amp;amp;M) and redirect the portlet to that specific folder .</summary>
    <dc:creator>Francisco Aires</dc:creator>
    <dc:date>2019-04-11T14:11:35Z</dc:date>
  </entry>
  <entry>
    <title>RE: How to link to a page with Document and Media Portlet with variable fol</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113147706" />
    <author>
      <name>Andrew Jardine</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113147706</id>
    <updated>2019-04-11T13:48:42Z</updated>
    <published>2019-04-11T13:48:42Z</published>
    <summary type="html">Hi Francisco,&lt;br /&gt;&lt;br /&gt;Let me see if I am following.&lt;br /&gt;&lt;br /&gt;1. You are using the Document Library to store your assets so you are creating DLFolder and DLFileEntry objects&lt;br /&gt;2. You have a Service Builder module that creates some data that points to the DLFolders&lt;br /&gt;3. You have a custom portlet that you created that you want to use to provide users with the list of folders and the option to click on the folder to view the contents&lt;br /&gt;&lt;br /&gt;.. is that right? So to be clear, you have a custom portlet -- you are NOT using the Documents and Media Portlet that Liferay provides OOTB?</summary>
    <dc:creator>Andrew Jardine</dc:creator>
    <dc:date>2019-04-11T13:48:42Z</dc:date>
  </entry>
  <entry>
    <title>How to link to a page with Document and Media Portlet with variable folder</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113138528" />
    <author>
      <name>Francisco Aires</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113138528</id>
    <updated>2019-04-11T11:53:29Z</updated>
    <published>2019-04-11T11:53:29Z</published>
    <summary type="html">Hello there&lt;br /&gt;&lt;br /&gt;I&amp;#39;m developing a portlet with liferay-CE-GA-7 , have diferents records manage with services builder and each one has a folder . Now i need to create a link to that folder.&lt;br /&gt;I tried creating a link , with Liferay Javascript ThemeDisplay , Liferay.ThemeDisplay.getLayoutURL()+&amp;#39;/-/document_library/&amp;#39;+Liferay.authToken+&amp;#39;/view/DLFolderId but with no success , it remain on the page&lt;br /&gt;&lt;br /&gt;Still looking for a solution&lt;br /&gt;Apreciate any help&lt;br /&gt;&lt;br /&gt;Regards &lt;br /&gt;​​​​​​​Francisco  </summary>
    <dc:creator>Francisco Aires</dc:creator>
    <dc:date>2019-04-11T11:53:29Z</dc:date>
  </entry>
</feed>
