When clicking in folder_contents leads to downloads (Plone)

published Aug 01, 2010 02:58   by admin ( last modified Aug 01, 2010 02:58 )

Summary: Add the portal_type on a line in the property "typesUseViewActionInListings" in the site_properties property sheet in portal_properties, and you will get the view instead

 

Having created my own MP3 content type in Plone, based on the File content type, I noticed the strange behavior that clicking on any MP3 in a folder contents listing would lead to a download of the MP3. Awkward.

Trying out the standard File content type, this does not happen; you get to the view of the content item instead.

So what's the difference? With File, there is "/view" appended to the url of each content item in the folder contents listing, with the MP3 file there is not. Time to look through the view configurations in XML for the two content types. There were differences, specifically File tacks on "/view" to the specification of "View". Changing this in MP3 made no difference.

Ok, time to take on the diving suit and chase down the code for the folder_contents view. Thankfully it was reasonably easy to find, in

./plone/app/content/browser/foldercontents.py

The view decides to tack on "/view" if the content type of the item to list is in this list:

use_view_action = site_properties.getProperty('typesUseViewActionInListings', ())

So, I added "MP3" on a line in the property "typesUseViewActionInListings" in the site_properties property sheet in portal_properties. And it worked. Not so obvious.