Folder items, sort alphabetically

Hello,

we use Plone to manage our documents. The person who implemented and maintained Plone is no longer employed in the company. I kind of inherited this project.

We use:
Plone 4.3.1 (4306)
CMF 2.2.7
Zope 2.13.20

Basically we have folders, containing subfolders, which contain documents (doc, pdf, ...)

MainFolder
...Subfolder_1
......Subfolder_1_1
......Subfolder_1_2
...Subfolder2
......Subfolder_2_1
.........Document1.doc
.........Document2.doc

Recently it was demanded, that the listed subfolders and documents should be sorted alphabetically.
Using the documentation I couldn't find a solution yet.

What works, is if I am in a folder on the tab "Contents", to arrange items manually. When I change to the tab "View" my arrangement is saved.

If I am in a folder on the tab "Contents" and click "title" or "modified" the items are arranged according to the column. But when I change back to "view" the sorting isn't saved and back to the way it was before.

Am I missing something, or doing something wrong?
Or is there a smarter way to achieve an alphabetically sorting of all folders and in all folders?

Can anyone help me, or point me in the right direction?

Thanks in advance for any help.
Kind Regards
Markus

It is possible to add a "Collection" to a folder.
Then you can set the 'default view' of the folder to the collection (Content Item as Default view).
For a Collection, you can choose criteria, like where to look, what kind of content types. And you can set 'sort on'.

In you case you would add a collection, make the criteria 'in (this) parent folder' and sort on "Title", alphabetically.

Note: this would not sort the folder, it will just list the content alphabetically (which is probably just as good)

1 Like

Hi Espen,

thanks for your reply. I got your solution basically working.

It works great for something like this:

Folder
...File_1
...File_2
...File_3

But regarding folders I have the problem that too much is displayed as a result of the collection.

Folder Setup:

ParentFolder
..SubFolder_1
....SubSubFolder_1
..SubFolder_2
..SubFolder_3

What I would like to see, when selecting the ParentFolder:
SubFolder_1
SubFolder_2
SubFolder_3

What I get, when I add a collection:
search criteria 1 -> Absolute Path = /Plone/ParentFolder/
search criteria 2 -> type = folder

Collection result:
ParentFolder
SubFolder_1
SubFolder_2
SubFolder_3
SubSubFolder_1

Is there a way to adjust search criteria for a better result?
"Search for Folders directly in this path,not below and don't show the ParentFolder" would be the logic I'm looking for.

Kind regards
Markus

Hallo Markus,

if you are not able resolving this request by collections you could maybe try changing this view with javascript?! What View is it you'd like to change? Is it 'List' ('Liste' in DE/AT/CH)?

Hi Jan,

currently it is list (Liste) and table (Tabelle), but I can change it all to list.
Where would I find the javascript, to alter this view?
And is it just a parameter I'd have to change or do I have to write new code?

Thanks.

Markus

Hi Markus,

this should be easy writing /adapting. You could find lots of examples e.g. on stackoverflow. I know it is most probably not best style in Plone doing it like this way:
For not changing templates (what would be easy here: you had a new view 'List Alphabetically' - but after upgrading Plone it could be you had to change this template again) i think it is ok using for example 'Catagorization': Giving this folder a catagory like 'AlphabeticList', then add a js-file in ZMI/portal_skins/custom, register it in ZMI/portal_javascripts (set this to debug and reload page, then uncheck debug-mode again).
So in js check if Catagory contains the above 'AlphabeticList' for this Folder and if so reorder items. Keep in mind : as always there shouldn't be too many item in this folder, espacially if the view will only list first 20 of 100 it'll not work.
On the other hand there are some addons for listing content in other ways, maybu you'll find one bespoken here in this community.

So this is what works for me with list-view:

$( document ).ready(function(){ var $divs = $("div.tileItem"); if ($(".link-category:contains('ListContentAlphabetically')").length) { var alphabeticallyOrderedDivs = $divs.sort(function (a, b) { return $(a).find("a.contenttype-folder").text() > $(b).find("a.contenttype-folder").text(); }); $("#content").append(alphabeticallyOrderedDivs); } });
You will need to adapt here used elemt-id's for to fit the ones used in the theme used.
After adding ListContentAlphabetically as category the list-view-items are sorted alphabetically.
PS: Thanks @tmassman, I'll try sortmyfolder tomorrow, did not know this one.

There's an add-on somewhere with "subtractive criteria" that might help, haven't used it though.

Hi, for Plone 4 you can use https://pypi.python.org/pypi/collective.sortmyfolder/1.0.7.

Plone Foundation Code of Conduct