Why are existing so many different file views?

I play a little bit with the Views for Filetype. In a plain Plone i find some views for a file:

  • /@@display-file --> Download the File
  • /@@download --> Download the File
  • /@@file_view --> View with a Template from plone.app.contenttypes
  • /view --> View with a Template from plone.app.contenttypes
  • /@@view --> a View or is this an Alias for what? looks like generic dexterity view?

What i need: one view for Download and one View for Display (include download Button/Link via Widget) like in the 'file_view'. How can i unregister or override or redirect '/@@view' to '/view' (no, not via frontend webserver :wink: ) ?

I thought so far that definitions are the same?

  permission="zope2.View" />
  permission="zope2.View" />

As example:

I'm a little bit confused, but hey, that is Plone :wink:

As I understand it, @@ explicitly tells Plone that you mean the browser view, otherwise Plone tries to guess what you mean

I learned a lot going through the Mastering Plone training class. Have you looked there for an explanation?

As Kim already explained, @@ (like ++) is a traversal directive: you never use it as part of a name.

You do not need an unregister or override for view/@@view. Overriding usually is based on your own (presentation) "layer" -- a standard "theme" component. A layer has a name and an associated interface. It is defined in a browserlayer.xml and registered via GenericSetup. After the registration, you can use the layer attribute of the ZCML browser directives to "bind" the registration to your layer; usually, it is more specific than the default registration and thus overrides.

If you really need to unregister something, you can use z3c.unconfigure. To use it, you must have located the original registration: usually, an unregistration looks like the registration (in the correct context and inside an unconfigure).

1 Like
  • @@file_view is the default view-view for the content type
  • view is the alias for the selected layout; if no layout is selected, the default view (@@file_view) is used.
  • @@view is a generic dexterity view, showing the display form for a dexterity content object

Usually the default view is used when you omit a specific view (so /my-page would be the same as /my-page/view), so the default view is the default view-view. But for files the default view is @@display-file, so you get a download instead.

This is the method alias chart from demo.plone.org:

I don’t know why there are two download views.

Sometimes I see folks registering the default view for a custom content type in ZCML as name=view. This will result in a customization/override of the generic dexterity @@view, and then view, @@view and no provided view name are the same. I don’t recommend that. Better is something like file_view, document_view etc.; EasyForm does that for example.

1 Like

Also, I would recommend to get rid of the dexterity @@view registration (using the before mentioned z3c.unconfigure), as it can confuse people and exposes internal content data which might not be desired, e.g. https://demo-latest-plone6.plone.org/de/demo/a-page/@@view also shows the blocks and blocks layout config. Some content types might have more sensible data.

1 Like

One thing I didn't read yet in the comments. There is/was a distinction in the download view vs display view in the mime/type and/or extra header information that is sent back to the browser: this to either force inline display with for example a PDF or Word/Excel inline viewing. or to always show a download popup to save the file on disk. The original file name can also be passed in this header. So the content item in Plone has id presentation-2021, but the file in the file field has id "Presentation_final_2021.pdf" and will be saved as such locally.

But in some browsers (IE, cough cough) if you once said "show inline" or 'save to disk" this would/could become the default and also sometimes silently happen on subsequent clicks. "My PDF is broken". No, IE silently stored it in your downloads folder......

The future of Internet Explorer on Windows 10 is in Microsoft Edge | Windows Experience Blog :slight_smile:

Plone Foundation Code of Conduct