================================================================================
How to override plone.app.discussion's comments viewlet
================================================================================
Override the comments template through-the web
----------------------------------------------
* go to the ZMI
* click on portal_view_customizations
* customize plone.comments (plone.app.discussion.interfaces.IDiscussionLayer)
Override the comments template with z3c.jbot on the file system
---------------------------------------------------------------
http://pypi.python.org/pypi/z3c.jbot
setup.py::
install_requires=[
...
'z3c.jbot',
],
configure.zcml::
Replace with a custom browserlayer of your package.
Create template directory::
$ mkdir overrides
Copy comments viewlet template to overrides directory::
$ cp ../parts/omelette/plone/app/discussion/browser/comments.pt overrides/plone.app.discussion.browser.comments.pt
Restart your Plone instance and you can start to customize your copy of the comments viewlet.
Override the comments viewlet class on the file system
------------------------------------------------------
interfaces.py::
from plone.app.discussion.interfaces import IDiscussionLayer
class IMyDiscussionLayer(IDiscussionLayer):
"""Marker interface for browser layer
"""
profiles/default/browserlayer.xml::
configure.zcml::
comments.py::
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from plone.app.discussion.browser.comments import CommentsViewlet as PloneAppDiscussionCommentsViewlet
from plone.app.discussion.browser.comments import CommentForm
class CommentsViewlet(PloneAppDiscussionCommentsViewlet):
form = CommentForm
index = ViewPageTemplateFile('comments.pt')
def get_commenter_home_url(self, username=None):
if username is None:
return None
else:
return "%s/memberhome/%s" % (self.context.portal_url(), username)
comment.pt::
...