Skip to content

Instantly share code, notes, and snippets.

@svx
Forked from pysailor/gist:772c4ae5f0ce7fd23ac6
Last active August 29, 2015 14:15
Show Gist options
  • Save svx/16660ca7168c798b1fbf to your computer and use it in GitHub Desktop.
Save svx/16660ca7168c798b1fbf to your computer and use it in GitHub Desktop.
Basically, http://docs.plone.org/develop/addons/components/zcml.html#specify-files-and-code-from-another-package explains how to do it. But the example is not very clear, since in both cases the same packge is referenced. Therefore, a simple example:
Suppose you want to overwrite the folder_contents view in Plone. You only need to change some code in the class and you're happy with the template.
The view is defined in plone.app.content.browser with this zcml statement:
<browser:page
for="Products.CMFCore.interfaces._content.IFolderish"
class=".folder.FolderContentsView"
name="folder_contents"
template="templates/folder_contents.pt"
permission="cmf.ListFolderContents"
/>
In your own package, you create a class that extends FolderContentsView and performs whatever additional magic you need. To use your own version of folder_contents with your own class but the original template, you can add this to your package, which in this example is called "my.package"
<!-- override folder_contents -->
<configure package="plone.app.content.browser">
<browser:page
for="Products.CMFCore.interfaces._content.IFolderish"
class="my.package.browser.foldercontents.MyFolderContentsView"
name="folder_contents"
template="folder_contents.pt"
layer="my.package.interfaces.IMyPackageLayer"
permission="cmf.ListFolderContents"
/>
</configure>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment