Created
February 19, 2015 13:17
-
-
Save pysailor/772c4ae5f0ce7fd23ac6 to your computer and use it in GitHub Desktop.
Plone: Override a browser view while keeping the original template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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