Skip to content

Commit c5ff42d

Browse files
committed
add how to enable and disable behaviors
1 parent c97867a commit c5ff42d

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

docs/backend/behaviors.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,47 @@ Overall, behaviors are an important part of the Plone content management system
7373

7474
## Adding or removing a behavior from a type
7575

76-
Given you already have an add-on for customizations with a setup profile...
76+
There are two ways to add or remove a behavior on a type:
77+
78+
- through the web using the control panel
79+
- using a custom add-on GenericSetup profile
80+
81+
### Through the Web
82+
83+
1. Go to the Site Setup and chose the Content Types control panel
84+
2. Select the type where you want to add or remove a behavior
85+
3. Then click on the Behaviors tab of the types settings.
86+
4. A list of all available behaviors appears.
87+
Select or unselect the checkbox of the behavior you want to add to or remove from the type.
88+
5. Save the form by clicking on the Save button at the bottom of the page.
89+
90+
### Using a GenericSetup profile
91+
92+
Given you already have a custom add-on with a `profiles/default` directory.
93+
Given we created a custom behavior named `mybehavior.subtitle`.
94+
95+
If you want to enable a behavior on an existing content type, create a new directory `types` under `profiles/default`.
96+
In there create a file named the same as the content type you want to change.
97+
In the example here, you want to add a behavior to the built-in Event type.
98+
The file to create is named `Event.xml` and it is a Factory Type Information definition.
99+
You need to change the behaviors configuration only so that all other parts can be omitted.
100+
This looks like so:
101+
102+
```XML
103+
104+
<?xml version="1.0"?>
105+
<object
106+
i18n:domain="plone"
107+
meta_type="Dexterity FTI"
108+
name="Event"
109+
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
110+
<property name="behaviors" purge="false">
111+
<element value="myproject.subtitle" />
112+
</property>
113+
</object>
114+
```
115+
116+
After you apply the profile (or uninstall and install the custom add-on), the behavior is available on the Event content type.
77117

78118
## How behaviors are working
79119

@@ -247,7 +287,7 @@ This field is not displayed in most views.
247287
To display the data entered in this field you need to modify the page template and access the `price_net` field as `context.price_net` there.
248288
To access the `price_vat` and `price_gross` fields you need to get the adapter in your view class like so:
249289

250-
```python
290+
```Python
251291
from .price import IPriceBehavior
252292

253293
class SomeViewClass:
@@ -259,4 +299,4 @@ class SomeViewClass:
259299
def gross(self):
260300
adapter = IPriceBehavior(context)
261301
return adapter.price_gross
262-
```
302+
```

0 commit comments

Comments
 (0)