Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Paul Masterson
Order Document Library files
October 15, 2010 3:45 AM
Answer

Paul Masterson

Rank: New Member

Posts: 16

Join Date: October 12, 2009

Recent Posts

Hi

Is it possible to order the 'Document Library' files by date.

I am sure it is some config file, but it's Friday and at this stage I am half blind
Paul Masterson
RE: Order Document Library files
October 18, 2010 3:55 AM
Answer

Paul Masterson

Rank: New Member

Posts: 16

Join Date: October 12, 2009

Recent Posts

Any takers for this one?
Oliver Bayer
RE: Order Document Library files
October 18, 2010 4:21 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 883

Join Date: February 18, 2009

Recent Posts

Hi Paul,

afaik it's only possible if you write an own comparator and modify jsps. But if you've found a better solution let me know.

Greets Oli
Paul Masterson
RE: Order Document Library files
October 18, 2010 4:25 AM
Answer

Paul Masterson

Rank: New Member

Posts: 16

Join Date: October 12, 2009

Recent Posts

Thank you I appreciate your reply

Would you know what jsp's to modify?


Thanks


Paul
Oliver Bayer
RE: Order Document Library files
October 19, 2010 7:09 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 883

Join Date: February 18, 2009

Recent Posts

Hi,

I don't find a solution till now but maybe you can use my hints to get it working.

1) In the view.jsp of the document library portlet (path: /html/portlet/document_library/) you will found around line 180 the search container which shows the files of a folder.

2) If you want to add a new column like e.g. date you have to possibilities. You can modify the portlet-custom.xml and add the following to the preferences of the document library display portlet:
1<preference>
2   <name>fileEntryColumns</name>
3   <value>name,size,date</value>
4</preference>

or you can add the following line to the init-ext.jsp of the document library:
1String[] fileEntryColumns = StringUtil.split("name,size,date,action");

Now you see a new header of the result table but no output.

3) To get the date output you have to modify the file_entry_columns.jspf and add a new c:when block.
1<c:when test='<%= fileEntryColumn.equals("date") %>'>
2  <liferay-ui:search-container-column-text
3     href="<%= rowHREF %>"
4     name="<%= fileEntryColumn %>"
5     value="<%= String.valueOf(fileEntry.getCreateDate()) %>"
6  />
7</c:when>

Now you should see the date of each file entry of the result table.

The sorting can maybe done via Collections.sort(result, your-comparator-to-write). Or you can use the "FileEntryModifiedDateComparator".

HTH Oli
Paul Masterson
RE: Order Document Library files
October 22, 2010 7:40 AM
Answer

Paul Masterson

Rank: New Member

Posts: 16

Join Date: October 12, 2009

Recent Posts

Ollie

Brillant, that works perfectlyemoticon

What I did was add the date to the existing string and then added the C block as suggested

Thank you


Paul
Wafa Bouyahi
RE: Order Document Library files
June 10, 2013 10:28 AM
Answer

Wafa Bouyahi

Rank: New Member

Posts: 5

Join Date: May 3, 2013

Recent Posts

I followed the same steps in order to reorder the documents by creation date but nothing happened emoticon
I'm using liferay 6.0.5 . Any suggestions please
Oliver Bayer
RE: Order Document Library files
June 11, 2013 1:06 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 883

Join Date: February 18, 2009

Recent Posts

Hi Wafa,

what do you mean by "nothing happened"? Do you get any exceptions/ error messages on the tomcat console? Maybe some methods changed in v6.0.5. You should give more info so we can -maybe/ hopefully emoticon- help.

Greets Oli
Wafa Bouyahi
RE: Order Document Library files
June 11, 2013 7:18 AM
Answer

Wafa Bouyahi

Rank: New Member

Posts: 5

Join Date: May 3, 2013

Recent Posts

Thanks for your reply ;)

In fact nothing happened because in document display i have just the name of the folder or the file so i can't see the added column "date".
But i just want that the default order of the files and the folders to be by creation date.
I didn't know how to apply the sorting here :
<liferay-ui:search-container-results
results="<%= DLFolderServiceUtil.getFolders(scopeGroupId, folderId, searchContainer.getStart(), searchContainer.getEnd()) %>"
total="<%= foldersCount %>"
/>
Thanks in advance emoticon
Wafa Bouyahi
RE: Order Document Library files
June 12, 2013 2:46 AM
Answer

Wafa Bouyahi

Rank: New Member

Posts: 5

Join Date: May 3, 2013

Recent Posts

Any suggestions please emoticon
Ricardo Vieira
RE: Order Document Library files
November 19, 2013 11:00 AM
Answer

Ricardo Vieira

Rank: Junior Member

Posts: 42

Join Date: August 16, 2010

Recent Posts

Does anyone have a suggestion on how to do this, I've managed to get the creation date in the dl display, but cant figure out where to do the sort by date emoticon

any help would be greatly appreciated emoticon

tnx
Oliver Bayer
RE: Order Document Library files
November 20, 2013 1:46 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 883

Join Date: February 18, 2009

Recent Posts

Hi Wafa, hi Racardo,

I don't have ported my sugguestions to v6.1 (v6.2) yet so I can give you only some hints on how you can maybe implement it. If you take a look at "view_entries.jsp" around line 116 you'll see an OrderByComparator object. Maybe it's sufficient if you add the newly added column to the orderableHeaders list. This would be the easiest solution but you can still write a custom comparator class (as described in one of my answers above) and use Collections.sort(results, YourComparator) before calling searchContainer.setResults(results) at line 244.

HTH Oli
Ricardo Vieira
RE: Order Document Library files
November 20, 2013 3:20 AM
Answer

Ricardo Vieira

Rank: Junior Member

Posts: 42

Join Date: August 16, 2010

Recent Posts

Thanks Oliver, you set me on the right track emoticon

My client has the 6.0.6 version, so I didnt find the "view_entries.jsp" and no OrderByComparator object but found the "view_file_entries.jspf" so what I did was setting the Collections.sort before setting the attribute "results" it worked, i need to refine the comparator but heres my first test if anyone needs it and works:

1    Collections.sort(results, new Comparator<DLFileEntry>() {
2                public int compare(DLFileEntry m1, DLFileEntry m2) {
3                    return m1.getCreateDate().compareTo(m2.getCreateDate());
4                }
5                });


tnx again emoticon
Oliver Bayer
RE: Order Document Library files
November 20, 2013 7:23 AM
Answer

Oliver Bayer

Rank: Liferay Master

Posts: 883

Join Date: February 18, 2009

Recent Posts

Hi Ricardo,

no problem, I'm glad I could help emoticon.
The jsps changed quite a bit from 5.2.3 to 6.1 and again for 6.2 that's why I could give only hints. But the possible solutions are still similar and writing a custom comparator should always work. Thanks for posting your solution - it could be helpful for others.

Regards Oli
Alessandro Lachina
RE: Order Document Library files
May 8, 2015 6:11 AM
Answer

Alessandro Lachina

Rank: New Member

Posts: 20

Join Date: June 12, 2013

Recent Posts

So what do you think we need to do to order on date in 6.2?
Any hints will be appreciated.
Thanks