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: Configure default sort order for Documents & Media portlet
Hi everbody.
We are using the Documents & Media portlet to offer a file space to our users.
By default, the portlet orders by "Modified date", but we want to change this default setting to "Order By: Title".I had a look at the portlet configuration, the control panel configuration, etc. but I don't see where to change this setting.
Maybe I'm missing something... can anybody please give me a hint?
Thanks in advance!
André
We are using the Documents & Media portlet to offer a file space to our users.
By default, the portlet orders by "Modified date", but we want to change this default setting to "Order By: Title".I had a look at the portlet configuration, the control panel configuration, etc. but I don't see where to change this setting.
Maybe I'm missing something... can anybody please give me a hint?
Thanks in advance!
André
Hi ,You can try setting the portal preference with orderByCol ,
PortalPreferences portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences(request);
portalPreferences.setValue("com_liferay_document_library_web_portlet_DLPortlet", "order-by-col", "title");
portalPreferences.setValue("com_liferay_document_library_web_portlet_DLPortlet", "order-by-type", "asc");
Thanks for your replay. I added the preferences to my portal-ext.properties (if possible, I want to avoid programmatical changes for this issue):
com_liferay_document_library_web_portlet_DLPortlet.order-by-col=title
com_liferay_document_library_web_portlet_DLPortlet.order-by-type=asc
After restarting, they appear in my Portal Properties (Server Administration -> Properties -> Portal Properties), but by default the Documents & Media still sorts by modified date. Am I missing something?
Hi
i dont think its will work adding in portal-ext.properties , it needs to added to database from below api.
i dont think its will work adding in portal-ext.properties , it needs to added to database from below api.
|
|
|
You're right, I ran it as a Groovy script and this did the trick:
import com.liferay.portlet.PortalPreferencesImpl;
import com.liferay.portal.kernel.portlet.PortletPreferencesFactoryUtil;
PortalPreferencesImpl portalPreferences = PortletPreferencesFactoryUtil.getPortalPreferences([i]--USER_ID--[/i], true);
portalPreferences.setValue("com_liferay_document_library_web_portlet_DLPortlet", "order-by-col", "title");
portalPreferences.setValue("com_liferay_document_library_web_portlet_DLPortlet", "order-by-type", "asc");
Thanks a lot!I just wonder why there is no way to configure this in the portlet configuration, the admin panel or at least via config file. I'll ask for a Jira account and write a feature request here.
Hiii,you did it for particular user but i want to do it for all users in my portal can you suggest me a way to do itthanks.
Hi ,
i think same code should apply to all user . as it might be apply preference to portal
i think same code should apply to all user . as it might be apply preference to portal
thanks for reply,but it's not applying for all users it's only applying for admin only.
thanks
thanks
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™