Modifying The Minimal Plone Content Type
Modifying The Minimal Plone Content Type
As you might have seen in My First Minimal Plone Content Type it was not trivial to create a minimal content type. But now that we have it in place it is quite easy to make drastic changes to it.
This first modification of it will only consist of changing the schema. Just modify the file message.py so that this is in the middle of it:
schema = BaseSchema.copy() + Schema(( DateTimeField('Date'), BooleanField('IsImportant'), BooleanField('BringBeer'), ImageField('Image'), TextField('Message', widget=TextAreaWidget()), ))
As you can see we have added a date-time field, two boolean fields, an image field and a text field. (For more about fields see for example this page [1] in the Archetypes Developer Manual). Also there is a named argument in the text field: the widget variable. As you can see we send in a text area widget. I hope you ask "why?", I certainly would.
The reason for using a text area widget in the text field instead of whatever is default is simple: the default widget is a widget that only stores one line of text (which sometimes is what you need - but not now).
Now adding a message looks something like this (note the calendar pop-up when you press the calendar icon):
Also note that the image in the middle of the schema is uploaded and stored automagically. Viewing the finished item now looks something like this:
Download
Download this version of My Message here: [2] .
This page belongs in Kategori Programmering
This page is part of a series of tutorials on Plone Cms.