Is it possible to disable a view of an uploaded HTML file in Plone 4.3

Hello! Can anyone help with this?

The first question is about Plone 4.3.17 and Dexterity content types. This is extremely important for me.

Is it possible to disable a view of an uploaded HTML file so as to render it as HTML instead of showing its code to the visitor?
What I mean is that an uploaded HTML file is not rendered as HTML to visitors but its code is showing.

In other words is it possible this link:
http://localhost:8080/ZeLem/en/publications-eng/PresCampain.html/view /// to be replaced by this:


and to render directly full screen. Also, I would like the file to be opened in a NEW browser window.
How can I accomplish all this? TTW is preferred since I am not a programmer.


  1. Second question:

is it possible to upload a folder to a Plone site?

  1. Third question:

Can an HTML file serve as a default view for a folder? To serve as a little sub-site?

view is typically used to show the metadata (title, author, ...) associated with a Plone content object. Usually, you would also start there editing of such an object. I doubt that you should try to get it always turned into the direct display view.

In portal_types --> <your type> --> Actions (when I remember right) you can control how virtual actions (like "view") are mapped to real views. When I remember right, there is also somewhere (likely in portal_types --> <your type>) and option which controls whether the view or the default action url is generated for some types (compare the configuration for e.g. File and Page).

It is a namedfile, so you can use this kind of url:
which means you can just append:


to the raw url file. This is an example with an html file:

Following Dieter advice, you should just find a way to set /@@display-file as default view for some objects, but portal_type does not apply here. Maybe you've to register a view.

Hello! Thank you very much, Yuri and Dieter, both of you ! It looks like combining your advises together worked for default behavior. I just added @@display-file in two places:

Dexterity FTI at /ZeLem/portal_types/File :
in ¨Available view methods¨
and in ¨Default view method¨ replaced file_view to @@display-file.
My question is now how to make it open in a New Window every time the request is made for that html/pdf from Navigation Portlet or Folder view?
And what if I want to have a different behavior for different file types?
Default behavior applies to all files. Appreciate a lot if you can answer also these too questions.

...and of course it should be mentioned that in code you can use:

<div tal-replace="structure my_html_object"><!-- Replaces the div with the HTML --></div>

To display the HTML rather than escaping it...
You could always write a simple view that can be used for this sort of thing...

When I remember right, then "actions" have a target property. This would allow you to control the target, when the link is generated by an "action", e.g. the "view action".
But, as far as I know there is no hook to control the target attribute of generated a elements (which controls in which window the link is presented) in general templates such as those for the navigation portlet and "folder_view". I see two options:

  1. You use customized templates for the "navigation portlet" and "folder_view".
  2. You use diazo (Plone's XSLT based output transform stage) to add the attribute in the final transform stage.

When I remember right, then the Plone documentation covers the basics for both approaches.

I assume that you mean by this "different behavior for files with different MIME type". The "MIME type" describes in a formal way, which type of content the file contains: is it e.g. HTML or plain text, PDF or MS excel, ...

I recommend not to implement different behavipr for files with different MIME type. Plone does not directly support that and browsers typically do a good job to handle files appropriately based on their MIME type.
However, should you really need this, then Plone file objects give you the associated MIME type as an attribute (potentially called content_type). In your implementation of the @@display-file view, you can behave differently according to the MIME type of the respective object.

In the diazo stage, the transformation process has no longer access to Plone objects: all it has is the generated [X]HTML. Therefore, it lacks the possibility to do things differently based on the MIME type of referenced objects. However, you can still use the "customize template" option to achieve this.

Hello Dieter and thank you. Customizing a template to add target attribute sounds fine to me.
About the different behavior you said:

"However, should you really need this, then Plone file objects give you the associated MIME type as an attribute (potentially called content_type). In your implementation of the @@display-file view, you can behave differently according to the MIME type of the respective object."

Could you please clarify this? Do you mean I can modify something else there and still control the behavior? Or are you just mentioning here basically that @@display-file view is self-sufficient?

Hello Netroxen, Thanks for replying! It seems I am getting some solutions but since you mentioned some code, this would be nice if you could give some more hints what did you mean for a "code dummy" like me?
Should it be written in a template and in which one? What is it in "structure my_html_object". "A simple view".
I mean what should be done exactly? a-b-c for dummies, please. At your free time, if you would like!!

Whether display-file is sufficient depends on what you want to change for different MIME types. In principle, display-file can control all details of the corresponding HTTP response - e.g. whether this returns HTML text or binary content. It cannot control the window where the output is presented (as this is decided by the browser -- before the display-file request).

Thank you a lot , Dieter!

Sorry for troubling you, may be you can also tell me : is there any way to upload a whole folder to the site. I know there are add-ons that upload multiple files. But how about a whole folder?

Access to the local file system of a user is not handled by Plone but by the browser (and potentially JS running in the browser). HTML supports only the upload of individual files. Everything else must be implemented by an extension running in the browser (or on the user's host). I, myself, have never had the need to support the upload of multiple files by users and I do not know the respective extensions.

Plone can (still) be configured to provide access via WebDAV and there are OS level extensions to embed a WebDAV source into the local file system. You can then use file system level commands to move/copy/delete things to/in Plone (provided the filenames are compatible with Plone). This can be an option if you have occasionally the need to mass import something; it is no solution when "normal" users should perform the upload.

If you have an extension that can upload multiple files, then you can emulate the upload of a folder by: create the target folder in Plone, enter the source folder; use the extension to upload the source folder content to the target folder. JS code can automate the creation of a folder in Plone; maybe, the whole process can be automated via JS (but I hope not, as it would mean that JS code can inspect the local file system and this would be a security risk).

Uploaded not by the user ,but by the site admin. The only need for me would be to upload a folder with multiple PDFs or HTMLS or JPEGS formats to the site as part of a site design to be available for reading or download by the user. Thank you a lot!

I would likely realize this as follows:

  • the site admin does not "upload a folder" but instead a zip archive (i.e. he has put the folder content beforehand into a "zip" archive).
  • the upload is handled by a special view which unpacks the zip archive and creates Plone content objects from its content.

I see, Thanks again.

Plone Foundation Code of Conduct