Skip to content

Commit 43f8e08

Browse files
authored
Merge branch '6.0' into updatetipvolto17.4.0
2 parents 4c09048 + 743034b commit 43f8e08

File tree

22 files changed

+1645
-474
lines changed

22 files changed

+1645
-474
lines changed

docs/backend/behaviors.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Other behaviors are implemented as add-on products, which can be installed and c
3030
Once a behavior has been installed, it can be applied to any content type by selecting it in the {guilabel}`Content Types` control panel.
3131
This allows items of this content type to gain the additional functionality provided by the behavior.
3232

33-
A key feature of behaviors is that they allow encapsulating functionality so that it can be reused for multiple content types without needing to reimplement it.
33+
A key feature of behaviors is that they allow encapsulating functionality so that it can be reused for multiple content types without needing to implement it again.
3434
Overall, behaviors are an important part of the Plone content management system and allow for powerful customization and extensibility of content objects.
3535

3636

@@ -40,7 +40,7 @@ Overall, behaviors are an important part of the Plone content management system
4040

4141
To view a complete list of built-in behaviors, browse to {guilabel}`Content Types` control panel, then click {guilabel}`Page` (or any other content type), then {guilabel}`Behaviors`.
4242

43-
| short name | Title | Desription |
43+
| short name | Title | Description |
4444
|---|---|---|
4545
| `plone.allowdiscussion` | Allow discussion | Allow discussion on this item |
4646
| `plone.basic` | Basic metadata | Adds title and description fields. |
@@ -72,11 +72,11 @@ To view a complete list of built-in behaviors, browse to {guilabel}`Content Type
7272
| `volto.preview_image` | Preview Image | Preview image for listings |
7373
| `volto.preview_image_link` | Preview Image Link | Preview image for listings based on links |
7474
| `plone.relateditems` | Related items | Adds the ability to assign related items |
75-
| `plone.richtext` | RichText | Adds richtext behavior |
75+
| `plone.richtext` | RichText | Adds RichText behavior |
7676
| `plone.shortname` | Short name | Gives the ability to rename an item from its edit form. |
7777
| `plone.tableofcontents` | Table of contents | Adds a table of contents |
78-
| `plone.thumb_icon` | Thumbs and icon handling | Options to suppress thumbs and/or icons and to override thumb size in listings, tables etc.
79-
| `plone.versioning` | Versioning | Versioning support with CMFEditions |
78+
| `plone.thumb_icon` | Thumbs and icon handling | Options to suppress thumbs or icons and to override thumb size in listings, tables, and other user interface elements |
79+
| `plone.versioning` | Versioning | Versioning support with `CMFEditions` |
8080

8181
```{todo}
8282
For each behavior in the table above, one may view the source code of the checkbox (its `name` attribute) to view its Short Name.
@@ -307,7 +307,7 @@ You do not *need* to know this, but it may help if you run into problems.
307307
```
308308

309309
In Plone, behaviors can be globally enabled on content types at runtime.
310-
With add-ons, behaviors can be enabled even on a single content object or for a whole subtree in the content hierarchy.
310+
With add-ons, behaviors can be enabled even on a single content object or for a whole subdirectory tree in the content hierarchy.
311311

312312

313313
### Interfaces and adapters
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
myst:
3+
html_meta:
4+
"description": "Creating content types to manage tasks in Plone."
5+
"property=og:description": "Creating content types to manage tasks in Plone."
6+
"property=og:title": "Creating content types to manage tasks in Plone."
7+
"keywords": "Content Types, FTI, Dexterity, plonecli, bobtemplates.plone"
8+
---
9+
10+
# Creating content types
11+
12+
When we attempt to solve a particular content management problem with Plone, we will often design new content types.
13+
For the purpose of this example, we'll build a simple set of types to manage tasks.
14+
15+
- We will use a content type `Tasks` to hold all task objects and present a list of tasks to the user.
16+
This type is folderish (`Container`).
17+
- We will use a content type `Task` with the information about the task.
18+
Fields include name, description, and status of the task.
19+
This type is non-folderish (`Item`).
20+
21+
## Creating a Plone package
22+
23+
We typically create a content type inside a Plone package.
24+
We will use the {term}`plonecli` to create a Plone package and our content types.
25+
26+
```shell
27+
plonecli create addon collective.tasks
28+
cd collective.tasks
29+
```
30+
31+
## Adding content types
32+
33+
Let's add a content type called `Tasks`:
34+
35+
```shell
36+
plonecli add content_type
37+
```
38+
39+
Fill in the name `Tasks` for the first content type:
40+
41+
```console
42+
-> Content type name (Allowed: _ a-z A-Z and whitespace) [Todo Task]: Tasks
43+
```
44+
45+
We keep the default base class `Container` here:
46+
47+
```console
48+
--> Dexterity base class (Container/Item) [Container]:
49+
```
50+
51+
We keep the default `globally addable`:
52+
53+
```console
54+
--> Should the content type globally addable? [y]:
55+
```
56+
57+
We want to filter content types, which can be added to this container:
58+
59+
```console
60+
--> Should we filter content types to be added to this container? [n]: y
61+
```
62+
63+
We keep the default behaviors active:
64+
65+
```console
66+
--> Activate default behaviors? [y]:
67+
```
68+
69+
Now let's add a content type called `Task`:
70+
71+
```shell
72+
plonecli add content_type
73+
```
74+
75+
Fill in the name `Task` for the first content type:
76+
77+
```console
78+
-> Content type name (Allowed: _ a-z A-Z and whitespace) [Todo Task]: Task
79+
```
80+
81+
We change the base class to `Item` here:
82+
83+
```console
84+
--> Dexterity base class (Container/Item) [Container]: Item
85+
```
86+
87+
We don't want it to be globally addable `globally addable`:
88+
89+
```console
90+
--> Should the content type globally addable? [y]: n
91+
```
92+
93+
If we disable `globally addable`, the next question will ask for the parent content type, where we will answer `Tasks`:
94+
95+
```console
96+
--> Parent container portal_type name: Tasks
97+
```
98+
99+
For the rest of the questions, we can keep the defaults.
100+
101+
To test our new Plone package and its content types, we can use {term}`plonecli` to build a development environment and start Plone.
102+
103+
```shell
104+
plonecli build
105+
plonecli serve
106+
```
107+
108+
Your Plone is now running on http://localhost:8080.
109+
You can add a new Plone site, enable your add-on, and add your content types.
110+
111+
```{seealso}
112+
{term}`plonecli` takes care of all the details of a content type and its configuration.
113+
For more configuration details, see {doc}`fti`.
114+
```
115+
116+
For now your content type doesn't have any custom schema with fields defined.
117+
118+
See {doc}`/backend/schemas`, {doc}`/backend/fields` and {doc}`/backend/widgets` for information on how to add custom fields and widgets to your content type.
119+
120+
Also have a look at Plone {doc}`/backend/behaviors`, which provide default features you can enable per content type.

docs/backend/content-types/fti.md

Lines changed: 221 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
---
2+
myst:
3+
html_meta:
4+
"description": "Factory type information (FTI) is responsible for content creation in portals in Plone."
5+
"property=og:description": "Factory type information (FTI) is responsible for content creation in portals in Plone."
6+
"property=og:title": "Factory Type Information (FTI)"
7+
"keywords": "Content Types, FTI"
8+
---
9+
10+
(backend-content-types-fti-label)=
11+
12+
# Factory Type Information (FTI)
13+
14+
A content type is defined by creating a {term}`Factory Type Information` (FTI) object.
15+
16+
To create an FTI in a `GenericSetup` profile, add the content type to the list in `types.xml`.
17+
For example, this adds the standard Plone page (`Document`) content type:
18+
19+
```xml
20+
<object name="portal_types">
21+
<object name="Document" meta_type="Dexterity FTI" />
22+
</object>
23+
```
24+
25+
Then add a file to the `types` directory with the same name.
26+
In this example, the file is `types/Document.xml` and contains this XML:
27+
28+
```xml
29+
<?xml version="1.0" encoding="utf-8"?>
30+
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
31+
meta_type="Dexterity FTI"
32+
name="Document"
33+
i18n:domain="plone"
34+
>
35+
36+
<!-- Basic properties -->
37+
<property name="title"
38+
i18n:translate=""
39+
>Page</property>
40+
<property name="description"
41+
i18n:translate=""
42+
/>
43+
44+
<property name="allow_discussion">False</property>
45+
<property name="factory">Document</property>
46+
<property name="icon_expr">string:contenttype/document</property>
47+
48+
<!-- Hierarchy control -->
49+
<property name="allowed_content_types" />
50+
<property name="filter_content_types">True</property>
51+
<property name="global_allow">True</property>
52+
53+
<!-- Schema, class and security -->
54+
<property name="add_permission">plone.app.contenttypes.addDocument</property>
55+
<property name="klass">plone.app.contenttypes.content.Document</property>
56+
<property name="model_file">plone.app.contenttypes.schema:document.xml</property>
57+
<property name="model_source" />
58+
<property name="schema" />
59+
60+
<!-- Enabled behaviors -->
61+
<property name="behaviors"
62+
purge="false"
63+
>
64+
<element value="plone.namefromtitle" />
65+
<element value="plone.allowdiscussion" />
66+
<element value="plone.excludefromnavigation" />
67+
<element value="plone.shortname" />
68+
<element value="plone.dublincore" />
69+
<element value="plone.richtext" />
70+
<element value="plone.relateditems" />
71+
<element value="plone.versioning" />
72+
<element value="plone.tableofcontents" />
73+
<element value="plone.locking" />
74+
</property>
75+
76+
<!-- View information -->
77+
<property name="add_view_expr">string:${folder_url}/++add++Document</property>
78+
<property name="default_view">document_view</property>
79+
<property name="default_view_fallback">False</property>
80+
<property name="immediate_view">view</property>
81+
<property name="view_methods">
82+
<element value="document_view" />
83+
</property>
84+
85+
<!-- Method aliases -->
86+
<alias from="(Default)"
87+
to="(dynamic view)"
88+
/>
89+
<alias from="edit"
90+
to="@@edit"
91+
/>
92+
<alias from="sharing"
93+
to="@@sharing"
94+
/>
95+
<alias from="view"
96+
to="(selected layout)"
97+
/>
98+
99+
<!-- Actions -->
100+
<action action_id="view"
101+
category="object"
102+
condition_expr=""
103+
icon_expr="string:toolbar-action/view"
104+
title="View"
105+
url_expr="string:${object_url}"
106+
visible="True"
107+
i18n:attributes="title"
108+
>
109+
<permission value="View" />
110+
</action>
111+
<action action_id="edit"
112+
category="object"
113+
condition_expr="not:object/@@plone_lock_info/is_locked_for_current_user|python:True"
114+
icon_expr="string:toolbar-action/edit"
115+
title="Edit"
116+
url_expr="string:${object_url}/edit"
117+
visible="True"
118+
i18n:attributes="title"
119+
>
120+
<permission value="Modify portal content" />
121+
</action>
122+
123+
</object>
124+
```
125+
126+
The `name` attribute on the root element in the XML must match the name in the filename and the name listed in `types.xml`.
127+
128+
Set the `i18n:domain` to the i18n domain which includes translations for this content type.
129+
This is usually the same as the name of the Python package which contains the content type.
130+
131+
132+
(global-fti-properties-label)=
133+
134+
## Global FTI properties
135+
136+
The XML sets a number of FTI properties that are used globally, in both Classic UI and Volto:
137+
138+
`action` elements
139+
: Defines additional {doc}`actions </backend/portal-actions>` which are available for this content type.
140+
141+
`add_permission`
142+
: ID of the permission controlling whether the current user has permission to add this content type.
143+
144+
`allow_discussion`
145+
: Boolean.
146+
Controls whether Plone's commenting system is enabled by default for this content type.
147+
148+
`allowed_content_types`
149+
: List of content types which can be added inside this one.
150+
Only used if `filter_content_types` is `True`.
151+
152+
`behaviors`
153+
: List of {doc}`behaviors </backend/behaviors>` enabled for this content type.
154+
155+
`description`
156+
: Short description displayed in the user interface.
157+
158+
`factory`
159+
: Name of the factory adapter used to create new instances of the content type.
160+
Usually the same as the content type name.
161+
162+
`filter_content_types`
163+
: Boolean.
164+
Controls which content types can be added inside this one.
165+
If `True`, allow only the types listed in `allowed_content_types`.
166+
If `False`, allow any content type that the user has permission to add.
167+
168+
`global_allow`
169+
: Boolean.
170+
Set to `True` to allow adding the content type anywhere in the site where the user has permission.
171+
Set to `False` to only allow adding it inside other content types that include this one in `allowed_content_types`.
172+
173+
`klass`
174+
: Dotted path to the Python class for this content type.
175+
176+
`model_file`
177+
: Location of an XML file to load as the content type's schema.
178+
This is an alternative to `schema` and `model_source`.
179+
180+
`model_source`
181+
: Inline XML schema for the content type.
182+
This is an alternative to `schema` and `model_file`.
183+
184+
`schema`
185+
: Dotted path to the Python schema for this content type.
186+
One of `model_file`, `model_source`, and `schema` must be set.
187+
`schema` is the most commonly used.
188+
189+
`title`
190+
: The name of the content type displayed in the user interface.
191+
192+
193+
(classic-ui-only-fti-properties-label)=
194+
195+
## Classic UI only FTI properties
196+
197+
The following FTI properties are used only in Classic UI:
198+
199+
`add_view_expr`
200+
: {term}`TALES` expression returning the URL of the form to add a new item of this content type.
201+
202+
`alias` elements
203+
: Controls a mapping from URL to views.
204+
It's not common to change this.
205+
206+
`default_view`
207+
: Name of the default view used to display this content type.
208+
209+
`default_view_fallback`
210+
: Boolean.
211+
If `True`, the `default_view` will be used if the assigned view is not found.
212+
213+
`icon_expr`
214+
: {term}`TALES` expression returning the name of one of the registered icons.
215+
See {doc}`/classic-ui/icons`.
216+
217+
`immediate_view`
218+
: Name of the view alias to display after a new item is added.
219+
220+
`view_methods`
221+
: List of views which can be selected to display this content type.

0 commit comments

Comments
 (0)