Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to link to a page with Document and Media Portlet with variable fol
Hello there
I'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.
I tried creating a link , with Liferay Javascript ThemeDisplay , Liferay.ThemeDisplay.getLayoutURL()+'/-/document_library/'+Liferay.authToken+'/view/DLFolderId but with no success , it remain on the page
Still looking for a solution
Apreciate any help
Regards
Francisco
I'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.
I tried creating a link , with Liferay Javascript ThemeDisplay , Liferay.ThemeDisplay.getLayoutURL()+'/-/document_library/'+Liferay.authToken+'/view/DLFolderId but with no success , it remain on the page
Still looking for a solution
Apreciate any help
Regards
Francisco
Hi Francisco,
Let me see if I am following.
1. You are using the Document Library to store your assets so you are creating DLFolder and DLFileEntry objects
2. You have a Service Builder module that creates some data that points to the DLFolders
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
.. 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?
Let me see if I am following.
1. You are using the Document Library to store your assets so you are creating DLFolder and DLFileEntry objects
2. You have a Service Builder module that creates some data that points to the DLFolders
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
.. 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?
Just to clarify, maybe i didn't make myself clear
I have a custom Portlet but i also use the OOTB D&M porlet. I need to control what the folder OOTB D&M portlet shows with some url parameter
My point is to create a button with href (by parameterize the url that point to the portlet D&M) and redirect the portlet to that specific folder .
I have a custom Portlet but i also use the OOTB D&M porlet. I need to control what the folder OOTB D&M portlet shows with some url parameter
My point is to create a button with href (by parameterize the url that point to the portlet D&M) and redirect the portlet to that specific folder .
I've answered this now 3 times and my reply keeps getting lost. If this works, I'll try once more.
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)
... so now my next two questions are.
1. Do you have a JSP you can use? or do you have to render it in Javascript?
2. Are you able to share any of your code with us?
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));
... so now my next two questions are.
1. Do you have a JSP you can use? or do you have to render it in Javascript?
2. Are you able to share any of your code with us?
I'm using one JSP that display a table empty.
Therefore i use a javascript function calling a service to get the customeres and populate my table.
function display(portletnamespace){
Liferay.Service(
'/patient.patient/get-customers',
{
start: 0,
end: 20,
},
function(result){
var table= [];
for(i=0;i<20;i++) {
var customerFolderId=result.customerFolderId;
table.push(' <a class="btn btn-primary" href='PathForDocuments+"/-/document_library/view"+"&"+portletnamespace+"folderId="+customerFolderId'>
<span class="glyphicon glyphicon-download-alt"></span>Documents</a>');
$("#customer").html(table.join(''));
}
});
}
I need to create the PathForDocuments in the href . Maybe create a PortletURL in the portlet and pass it to the display ?
Thank you for following up
Therefore i use a javascript function calling a service to get the customeres and populate my table.
function display(portletnamespace){
Liferay.Service(
'/patient.patient/get-customers',
{
start: 0,
end: 20,
},
function(result){
var table= [];
for(i=0;i<20;i++) {
var customerFolderId=result.customerFolderId;
table.push(' <a class="btn btn-primary" href='PathForDocuments+"/-/document_library/view"+"&"+portletnamespace+"folderId="+customerFolderId'>
<span class="glyphicon glyphicon-download-alt"></span>Documents</a>');
$("#customer").html(table.join(''));
}
});
}
I need to create the PathForDocuments in the href . Maybe create a PortletURL in the portlet and pass it to the display ?
Thank you for following up
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.
Liferay. It will allow you to create a render, action or resource url in js and set the parameters dynamically.
Liferay. It will allow you to create a render, action or resource url in js and set the parameters dynamically.
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;
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.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™