Customize the Plone view class without touching the template

If the view is registered this way, with a template definition in zcml:

<browser:page
    name="original-view"
    class=".original_view.View"
    permission="zope2.View"
    for="*"
    template="original_template.pt"
    />

      

and I only want to customize my class in my product, is there a way to do this without customizing the template as well?

+3


source to share


1 answer


You have to wrap your browser page: <configure package='XXXX'>

This means that you are then within this packaging.

Example:

<configure package="original.package.browser">
    <!-- custom view -->
    <browser:page
        name="original-view"
        class="your.package.browser.View" <!-- Full dotted name to you custom view class -->
        permission="zope2.View"
        for="*"
        layer="your.package.interfaces.IYourPackageLayer" <!-- You should provide a browserlayer, otherwise you got a configuration conflict -->
        template="original_template.pt" <!-- template from original.package.browser -->
    />

</configure>

      



EDIT:

As @supup mentioned, I have updated the example code cut by layer If you cannot use the layer (BrowserLayer) you can put the code without the layer attribute in overrides.zcml

You can also specify more precise Interface

in the attributefor

+8


source







All Articles