How to override view/template of default content types

How to override view/template of a default content type (e.g. Document) with zcml? Since I need some logic and want to be explicit jbot is not suitable. Registering a new view as described in docs works like a charm.

I tried to register my view under the same name "document_view" using a custom layer:

  <browser:page
  name="document_view"
  for="plone.app.contenttypes.interfaces.IDocument"
  permission="zope2.View"
  class=".views.DocumentView"
  menu="plone_displayviews"
  layer="plonetheme.mytheme.interfaces.IPlonethemeMythemeLayer"
  title="Foo Bar"
  />

Any ideas?

Somethign like this should work:

    <browser:page
        for="plone.app.contenttypes.interfaces.IDocument"
        name="document_view"
        template="document.pt"
        class=".views.DocumentView"
        permission="zope2.View"
        layer="plonetheme.mytheme.interfaces.IPlonethemeMythemeLayer"
        />

Where the template document.pt and the class inside .views are located where configure is. Probably you will also need to make your layer inherite from: IPloneAppContenttypesLayer so your layer has more priority, like this:

from plone.app.contenttypes.interfaces import IPloneAppContenttypesLayer


class IPlonethemeMythemeLayer(IDefaultBrowserLayer, IPloneAppContenttypesLayer):
    """Marker interface that defines a browser layer.
    """

Other option is to register a view with a different name and change the default view of the Document

You can also use a overrides.zcml.

Plone Foundation Code of Conduct