diff --git a/docs/source/howtos/howto_extend_the_comment_form.txt b/docs/source/howtos/howto_extend_the_comment_form.txt index aadb3c7..6249329 100644 --- a/docs/source/howtos/howto_extend_the_comment_form.txt +++ b/docs/source/howtos/howto_extend_the_comment_form.txt @@ -1,29 +1,43 @@ +==================================================== Howto extend the comment form with additional fields ==================================================== This document explains how to extend the plone.app.discussion comment form with -additional fields in an add-on product. +additional fields in an add-on product. -.. seealso:: - - * See the github collective for the source code of this howto: - https://github.com/collective/collective.example.commentextender/ +plone.app.discussion uses the +`plone.z3cform.fieldsets `_ +package which provides support for modifications via "extender" adapters. The +idea is that a third party component can modify the fields in a form and the +way that they are grouped and ordered. .. note:: This howto applies only to plone.app.discussion >= 2.0.4 and >= 1.1.1. Prior versions will not store the extended fields on the comment. +.. seealso:: + + The source code of this howto can be found here: + https://github.com/collective/collective.example.commentextender/ + + +Howto extend the comment form with an additional "website" field +================================================================ + First, create a new plone package:: - $ paster create -t plone my.commentextender + $ paster create -t plone example.commentextender -Go to the main directory of the package (my.commentextender/my/commentextender) -and create a new file commentextender.py containing the ICommentExtenderFields -interface definition with an additional "website" field, a persistent -CommentExtenderFields class to actually store the "website" value, a -CommentExtenderFactory to create the CommentExtenderFields, and CommentExtender -class to actually extend the default comment form with the field:: +Go to the main directory of the package +(example.commentextender/example/commentextender) and create a new file +*commentextender.py*. + +This file contains the ICommentExtenderFields interface definition with a +"website" field, a persistent CommentExtenderFields class to store the value of +the "website" field, a CommentExtenderFactory to create the +CommentExtenderFields, and a CommentExtender class to extend the default +comment form with the "website" field:: from persistent import Persistent @@ -79,8 +93,8 @@ class to actually extend the default comment form with the field:: hide, and reorder fields: http://pypi.python.org/pypi/plone.z3cform#fieldsets-and-form-extenders -Now register the CommentExtenderFactory and CommentExtender Classes we just -created by adding the following lines to your configure.zcml:: +Now register the CommentExtenderFactory and CommentExtender Classes that has +been created by adding the following lines to your configure.zcml:: `_. to the setup.py +of the example.commentextender package:: install_requires=[ ... 'z3c.jbot', ], -Next, create a new directory called "overrides" inside the my.commentextender -package and register it together with z3c.jbot in your configure.zcml:: +Next, create a new directory called "overrides" inside the +example.commentextender package and register it together with z3c.jbot in your +configure.zcml:: - - +Restart your Plone instance and you will see the "website" field in the +documentByLine next to the comments. diff --git a/docs/source/howtos/index.txt b/docs/source/howtos/index.txt index 5dd10e6..5ef9cd7 100644 --- a/docs/source/howtos/index.txt +++ b/docs/source/howtos/index.txt @@ -1,7 +1,8 @@ +====== Howtos ====== .. toctree:: - :maxdepth: 2 + :maxdepth: 1 howto_extend_the_comment_form.txt