On a Plone site with the structure
root
+-topic1
| +-page1
| +-page2
|
+-topic2
+-page3
+-page4
I want to have a view for folder root
that lists the contents of the subfolders, like:
[http://host/plone/root/]
TOPIC1
- page1
- page2
TOPIC2
- page3
- page4
with "TOPIC1" and "TOPIC2" as headings and "page1" etc. linking to the actual pages.
Simply using a collection aggregating the pages in the topic1 and topic2 folders is not enough since it doesn't generate the subheadings.
I have searched the Plone products repository as well as the web for an extension providing a view like this, with no success. There are sources saying this can be done with custom Display Views, but since I am new to Plone, I hesitate to dig into hacking these.
Is there a Plone product/extension that can provide such a view on subfolder contents?
Or is there even a built-in solution that I am not aware of?
I figured it out.
Basically, what you want to do is extend the folder_summary_view
template to include a content list for folder and collection items.
Create a copy. In the ZMI, go to portal_skins/plone_content/folder_summary_view
and hit Customize. Go to the copy at portal_skins/custom/folder_summary_view
and rename it to (for example) list_contents
.
Activate it as folder view. Go to portal_types/Folder
and manually add list_contents
to the list in Available view methods.
Make sure the view only shows folders and collections. Wrap the code that generates the entry details in <tal:general_check condition="python: item_type in ('Folder', 'Topic')"> GENERATE ENTRY </tal:general_check>
Add the code for listing the item contents. You can steal it from portal_skins/plone_content/folder_listing
since this already does what is needed. Copy the <metal:listingmacro> ... <metal:listingmacro>
part, but replace the folderContents
definition in <tal:foldercontents>
with this line to retrieve the contents:
folderContents folderContents|nothing;
folderContents python:item_object.queryCatalog(**contentFilter) or
item_object.getFolderContents(contentFilter, batch=True, b_size=limit_display or 100);
(all in one line)
Note: item_object
is the name given to the item in the outer listing.
If you activate list_contents
as a folder view now, it works exactly as demanded in the question.
Warning: This is a copy-paste-hack by a Plone novice that works for me™. Use at your own risk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With