Reputation: 758
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?
Upvotes: 6
Views: 2012
Reputation: 3965
You can also achieve this just via the Plone-UI:
Install Products.ContentWellPortlets and assign two collection-portlets below the content to your portal's default-view-item (f.e. 'front-page' as by default).
Upvotes: 2
Reputation: 758
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.
Upvotes: 3
Reputation: 61
You could use a Collection here, with the two paths configured as criteria. And if you want to, you could use this collection as default view for "root". Have a look at the default "news" and "events" folders and collections, located in it.
http://plone.org/documentation/manual/plone-4-user-manual/using-collections/adding-collections
Upvotes: 0