Comment form extender documentation updated.
svn path=/plone.app.discussion/trunk/; revision=50078
This commit is contained in:
parent
7a7a708fc0
commit
1e331d957f
@ -1,29 +1,43 @@
|
|||||||
|
====================================================
|
||||||
Howto extend the comment form with additional fields
|
Howto extend the comment form with additional fields
|
||||||
====================================================
|
====================================================
|
||||||
|
|
||||||
This document explains how to extend the plone.app.discussion comment form with
|
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::
|
plone.app.discussion uses the
|
||||||
|
`plone.z3cform.fieldsets <http://pypi.python.org/pypi/plone.z3cform#fieldsets-and-form-extenders>`_
|
||||||
* See the github collective for the source code of this howto:
|
package which provides support for modifications via "extender" adapters. The
|
||||||
https://github.com/collective/collective.example.commentextender/
|
idea is that a third party component can modify the fields in a form and the
|
||||||
|
way that they are grouped and ordered.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
This howto applies only to plone.app.discussion >= 2.0.4 and >= 1.1.1. Prior
|
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.
|
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::
|
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)
|
Go to the main directory of the package
|
||||||
and create a new file commentextender.py containing the ICommentExtenderFields
|
(example.commentextender/example/commentextender) and create a new file
|
||||||
interface definition with an additional "website" field, a persistent
|
*commentextender.py*.
|
||||||
CommentExtenderFields class to actually store the "website" value, a
|
|
||||||
CommentExtenderFactory to create the CommentExtenderFields, and CommentExtender
|
This file contains the ICommentExtenderFields interface definition with a
|
||||||
class to actually extend the default comment form with the field::
|
"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
|
from persistent import Persistent
|
||||||
|
|
||||||
@ -79,8 +93,8 @@ class to actually extend the default comment form with the field::
|
|||||||
hide, and reorder fields:
|
hide, and reorder fields:
|
||||||
http://pypi.python.org/pypi/plone.z3cform#fieldsets-and-form-extenders
|
http://pypi.python.org/pypi/plone.z3cform#fieldsets-and-form-extenders
|
||||||
|
|
||||||
Now register the CommentExtenderFactory and CommentExtender Classes we just
|
Now register the CommentExtenderFactory and CommentExtender Classes that has
|
||||||
created by adding the following lines to your configure.zcml::
|
been created by adding the following lines to your configure.zcml::
|
||||||
|
|
||||||
<adapter
|
<adapter
|
||||||
factory=".commentextender.CommentExtenderFactory"
|
factory=".commentextender.CommentExtenderFactory"
|
||||||
@ -98,15 +112,17 @@ Since we do not only want to store the "website" value on the comments, but also
|
|||||||
to show these values for existing comments, we have to override the comments
|
to show these values for existing comments, we have to override the comments
|
||||||
viewlet. The easiest way to do this is to use z3c.jbot.
|
viewlet. The easiest way to do this is to use z3c.jbot.
|
||||||
|
|
||||||
First, add z3c.jbot to the setup.py of the my.commentextender package::
|
First, add `z3c.jbot <http://pypi.python.org/pypi/z3c.jbot>`_. to the setup.py
|
||||||
|
of the example.commentextender package::
|
||||||
|
|
||||||
install_requires=[
|
install_requires=[
|
||||||
...
|
...
|
||||||
'z3c.jbot',
|
'z3c.jbot',
|
||||||
],
|
],
|
||||||
|
|
||||||
Next, create a new directory called "overrides" inside the my.commentextender
|
Next, create a new directory called "overrides" inside the
|
||||||
package and register it together with z3c.jbot in your configure.zcml::
|
example.commentextender package and register it together with z3c.jbot in your
|
||||||
|
configure.zcml::
|
||||||
|
|
||||||
<configure
|
<configure
|
||||||
...
|
...
|
||||||
@ -137,5 +153,5 @@ You can now add code to show the website attribute to the documentByLine::
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Restart your Plone instance and you will see the "website" field in the
|
||||||
|
documentByLine next to the comments.
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
======
|
||||||
Howtos
|
Howtos
|
||||||
======
|
======
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 1
|
||||||
|
|
||||||
howto_extend_the_comment_form.txt
|
howto_extend_the_comment_form.txt
|
||||||
|
Loading…
Reference in New Issue
Block a user