How to override enable_conversation added.
This commit is contained in:
parent
80d70bbf08
commit
943661cf42
@ -1,6 +1,6 @@
|
||||
================================================================================
|
||||
===============================================================================
|
||||
How to override plone.app.discussion's comments viewlet
|
||||
================================================================================
|
||||
===============================================================================
|
||||
|
||||
This document explains how to override the plone.app.discussion comments
|
||||
viewlet that controls the way existing comments are displayed.
|
||||
|
@ -1,12 +1,25 @@
|
||||
==============================================================================
|
||||
Howto override the enable_conversation method.
|
||||
==============================================================================
|
||||
|
||||
configure.zcml::
|
||||
plone.app.discussion way to decide if commenting is enabled on a content
|
||||
object can be quite complex and cumbersome due to the need to be backward
|
||||
compatible with the way the old commenting system in Plone (<4.1) worked.
|
||||
|
||||
The comments viewlet calls the enabled method of the ConversationView to
|
||||
decide if the add comment form should show up:
|
||||
|
||||
.. literalinclude:: ../../../plone/app/discussion/browser/conversation.py
|
||||
:language: python
|
||||
:pyobject: ConversationView
|
||||
|
||||
If you want to override this behavior, you just have to create your own enabled method. To do so, we first have to register our custom
|
||||
ConversationView by overriding the existing one in our configure.zcml::
|
||||
|
||||
<configure
|
||||
xmlns="http://namespaces.zope.org/zope"
|
||||
xmlns:browser="http://namespaces.zope.org/browser"
|
||||
xmlns:plone="http://namespaces.plone.org/plone"
|
||||
xmlns:grok="http://namespaces.zope.org/grok"
|
||||
i18n_domain="freitag.behavior.allowdiscussion">
|
||||
i18n_domain="mycustompackage.discussion">
|
||||
|
||||
<!-- Override plone.app.discussion's conversation view -->
|
||||
<browser:page
|
||||
@ -18,21 +31,16 @@ configure.zcml::
|
||||
|
||||
</configure>
|
||||
|
||||
conversation.py
|
||||
Now we implement the conversation view with a single "enable" method in
|
||||
conversation.py::
|
||||
|
||||
from zope.component import queryUtility
|
||||
|
||||
from plone.registry.interfaces import IRegistry
|
||||
|
||||
from Acquisition import aq_base
|
||||
from Acquisition import aq_chain
|
||||
from Acquisition import aq_inner
|
||||
|
||||
from Products.CMFCore.utils import getToolByName
|
||||
from Products.CMFCore.interfaces import IFolderish
|
||||
|
||||
from Products.CMFPlone.interfaces import IPloneSiteRoot
|
||||
from Products.CMFPlone.interfaces import INonStructuralFolder
|
||||
|
||||
from plone.app.discussion.interfaces import IDiscussionSettings
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
================================================================================
|
||||
===============================================================================
|
||||
Howto write a custom email notification
|
||||
================================================================================
|
||||
===============================================================================
|
||||
|
||||
This document explains how to write a custom email notification for
|
||||
plone.app.discussion.
|
@ -6,3 +6,4 @@ Howtos
|
||||
:maxdepth: 1
|
||||
|
||||
howto_extend_the_comment_form.txt
|
||||
howto_override_enable_conversation.txt
|
||||
|
Loading…
Reference in New Issue
Block a user