[英]Customize Plone view class without touching the template
If a view is registered like this, with the template definition in zcml: 如果视图是这样注册的,则使用zcml中的模板定义:
<browser:page
name="original-view"
class=".original_view.View"
permission="zope2.View"
for="*"
template="original_template.pt"
/>
and i want to customize only his class in my product, is there a way to do it without customizing also the template? 我想在我的产品中只定制他的课程,有没有办法在不定制模板的情况下完成?
You have to wrap the browser:page by <configure package='XXXX'>
您必须通过
<configure package='XXXX'>
包装浏览器:page
That means your then in scope of this packge. 这意味着你在这个包装的范围内。
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 @sdupton mentioned, I updated the example code snipped with a layer If you can't use a layer (BrowserLayer) you can put the code, without layer attribute into a overrides.zcml
正如@sdupton所提到的,我更新了用图层剪切的示例代码如果你不能使用图层(BrowserLayer),你可以把代码,没有图层属性放入
overrides.zcml
You can also specify a more precise Interface
in the for
attribute 您还可以在
for
属性中指定更精确的Interface
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.