Skip to content

Commit 232db36

Browse files
committed
Add content type intro and FTI reference
1 parent 2b619fa commit 232db36

File tree

1 file changed

+216
-8
lines changed

1 file changed

+216
-8
lines changed

docs/backend/content-types/index.md

Lines changed: 216 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,223 @@ myst:
1212
# Content Types
1313

1414
```{seealso}
15-
See the chapter {ref}`training:dexterity1-label` from the Mastering Plone 6 Training.
15+
See the chapter {ref}`training:dexterity1-label` from the Mastering Plone 6 Training for a step-by-step tutorial to create a custom content type.
1616
```
1717

18-
```{todo}
19-
Contribute to this documentation!
20-
See issue [Backend > Content Types needs content](https://github.com/plone/documentation/issues/1303).
18+
## What is a content type?
19+
20+
Each item in a Plone site is an instance of a particular content type. We have different content types to reflect the different kinds of information about which we need to collect and display information.
21+
22+
Pages, news items, events, files (binary) and images are examples of content types.
23+
24+
Lots of things in Plone can be configured to work differently based on the content type. For example, each content type has:
25+
- a {ref}`schema <backend-fields-label>` specifying the fields which can be edited for the content type
26+
- a list of {ref}`behaviors <backend-behaviors-label>` which supply additional functionality that can be attached to the content types for which the behavior is enabled
27+
- a {ref}`workflow <backend-workflows-label>` controlling transitions between publishing states and associated permissions
28+
- a version policy controlling whether to store a revision history
29+
30+
It is common in developing a web site that you'll need customized versions of common content types, or perhaps even entirely new types.
31+
32+
## Factory Type Information
33+
34+
A content type is defined by creating a Factory Type Information (FTI) object.
35+
36+
To create an FTI in a GenericSetup profile, add the content type to the list in `types.xml`. For example, this adds the standard Plone page (Document) content type:
37+
38+
```xml
39+
<object name="portal_types">
40+
<object name="Document" meta_type="Dexterity FTI" />
41+
</object>
42+
```
43+
44+
Then, add a file to the `types` directory with the same name.
45+
In this example, the file is `types/Document.xml` and contains this XML:
46+
```xml
47+
<?xml version="1.0" encoding="utf-8"?>
48+
<object xmlns:i18n="http://xml.zope.org/namespaces/i18n"
49+
meta_type="Dexterity FTI"
50+
name="Document"
51+
i18n:domain="plone"
52+
>
53+
54+
<!-- Basic properties -->
55+
<property name="title"
56+
i18n:translate=""
57+
>Page</property>
58+
<property name="description"
59+
i18n:translate=""
60+
/>
61+
62+
<property name="allow_discussion">False</property>
63+
<property name="factory">Document</property>
64+
<property name="icon_expr">string:contenttype/document</property>
65+
<property name="link_target" />
66+
67+
<!-- Hierarchy control -->
68+
<property name="allowed_content_types" />
69+
<property name="filter_content_types">True</property>
70+
<property name="global_allow">True</property>
71+
72+
<!-- Schema, class and security -->
73+
<property name="add_permission">plone.app.contenttypes.addDocument</property>
74+
<property name="klass">plone.app.contenttypes.content.Document</property>
75+
<property name="model_file">plone.app.contenttypes.schema:document.xml</property>
76+
<property name="model_source" />
77+
<property name="schema" />
78+
79+
<!-- Enabled behaviors -->
80+
<property name="behaviors"
81+
purge="false"
82+
>
83+
<element value="plone.namefromtitle" />
84+
<element value="plone.allowdiscussion" />
85+
<element value="plone.excludefromnavigation" />
86+
<element value="plone.shortname" />
87+
<element value="plone.dublincore" />
88+
<element value="plone.richtext" />
89+
<element value="plone.relateditems" />
90+
<element value="plone.versioning" />
91+
<element value="plone.tableofcontents" />
92+
<element value="plone.locking" />
93+
</property>
94+
95+
<!-- View information -->
96+
<property name="add_view_expr">string:${folder_url}/++add++Document</property>
97+
<property name="default_view">document_view</property>
98+
<property name="default_view_fallback">False</property>
99+
<property name="immediate_view">view</property>
100+
<property name="view_methods">
101+
<element value="document_view" />
102+
</property>
103+
104+
<!-- Method aliases -->
105+
<alias from="(Default)"
106+
to="(dynamic view)"
107+
/>
108+
<alias from="edit"
109+
to="@@edit"
110+
/>
111+
<alias from="sharing"
112+
to="@@sharing"
113+
/>
114+
<alias from="view"
115+
to="(selected layout)"
116+
/>
117+
118+
<!-- Actions -->
119+
<action action_id="view"
120+
category="object"
121+
condition_expr=""
122+
icon_expr="string:toolbar-action/view"
123+
title="View"
124+
url_expr="string:${object_url}"
125+
visible="True"
126+
i18n:attributes="title"
127+
>
128+
<permission value="View" />
129+
</action>
130+
<action action_id="edit"
131+
category="object"
132+
condition_expr="not:object/@@plone_lock_info/is_locked_for_current_user|python:True"
133+
icon_expr="string:toolbar-action/edit"
134+
title="Edit"
135+
url_expr="string:${object_url}/edit"
136+
visible="True"
137+
i18n:attributes="title"
138+
>
139+
<permission value="Modify portal content" />
140+
</action>
141+
142+
</object>
21143
```
22144

23-
```{todo}
24-
Describe how to add a content type (Python/XML) including FTI settings.
25-
Fields, Widgets, Vocabularies are also described in detail in their own chapters, and will be referenced from examples here.
26-
```
145+
The `name` attribute on the root element in the XML must match the name in the filename and the name listed in `types.xml`.
146+
147+
Set the `i18n:domain` to the i18n domain which includes translations for this content type. This is usually the same as the name of the Python package which contains the content type.
148+
149+
The XML sets a number of FTI properties:
150+
151+
```{glossary}
152+
:sorted: true
153+
154+
title
155+
The name of the content type displayed in the UI.
156+
157+
description
158+
Short description displayed in the UI.
159+
160+
factory
161+
Name of the factory adapter used to create new instances of the content type.
162+
Usually the same as the content type name.
163+
164+
add_permission
165+
Id of the permission controlling whether the current user has permission to add this content type.
166+
167+
klass
168+
Dotted path to the Python class for this content type.
169+
170+
schema
171+
Dotted path to the schema for this content type.
172+
173+
model_file
174+
Location of an XML file to load as the content type's schema.
175+
This is an alternative to `schema` and `model_source`.
176+
177+
model_source
178+
Inline XML schema for the content type.
179+
This is an alternative to `schema` and `model_file`.
180+
181+
behaviors
182+
List of {ref}`behaviors <backend-behaviors-label>` enabled for this content type.
183+
184+
global_allow
185+
Boolean.
186+
Set to True to allow adding the content type anywhere in the site where the user has permission.
187+
Set to False to only allow adding it inside other content types that include this one in `allowed_content_types`.
188+
189+
filter_content_types
190+
Boolean. Controls which content types can be added inside this one.
191+
If True, allow only the types listed in `allowed_content_types`.
192+
If False, allow any content type that the user has permission to add.
193+
194+
allowed_content_types
195+
List of content types which can be added inside this one.
196+
Only used if `filter_content_types` is True.
197+
198+
allow_discussion
199+
Boolean. Controls whether Plone's commenting system is enabled for this content type.
200+
201+
`action` elements
202+
Defines additional {ref}`actions <backend-portal-actions-label>` which are available for this content type.
203+
```
204+
205+
The following FTI properties are only used in the Classic UI:
206+
207+
```{glossary}
208+
:sorted: true
209+
icon_expr
210+
TALES expression returning the name of one of the registered icons.
211+
See {ref}`classic-ui-icons-label`
212+
213+
link_target
214+
TODO
215+
216+
add_view_expr
217+
TALES expression returning the URL for the form to add a new item of this content type.
218+
219+
default_view
220+
Name of the default view used to display this content type.
221+
222+
default_view_fallback
223+
TODO
224+
225+
immediate_view
226+
Name of the view alias to display after a new item is added.
227+
228+
view_methods
229+
List of views which can be selected to display this content type.
230+
231+
`alias` elements
232+
Controls a mapping from URL to views.
233+
It's not common to change this.
234+
```

0 commit comments

Comments
 (0)