You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/developer-guide/create-control-panel.md
+31-17Lines changed: 31 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -15,36 +15,41 @@ This chapter describes how to create a control panel for your Plone add-on, whet
15
15
16
16
It also covers advanced topics—including how to group fields in your control panel—and provides a schema field reference, troubleshooting tips, control panel file structure, and a Plone REST API compatibility reference.
17
17
18
+
[`plonecli`](https://pypi.org/project/plonecli/) automates all the manual steps to create a control panel.
19
+
This chapter will walk through all those steps as well.
18
20
19
-
## Creation approaches
20
21
21
-
There are two approaches to create a control panel for your Plone add-on:
22
+
## `plonecli`
22
23
23
-
-[`plonecli`](https://pypi.org/project/plonecli/)
24
-
- manual
24
+
You can install `plonecli` as any other Python package.
25
+
Since it's used for development, it's advantageous to install it in your user environment, thus making it available to all your Plone projects.
25
26
27
+
```shell
28
+
pip install plonecli --user
29
+
```
26
30
27
-
### `plonecli`
28
-
29
-
To add a control panel to your add-on, you can use [`plonecli`](https://pypi.org/project/plonecli/) as follows.
31
+
You can automatically create a control panel using the following command.
30
32
31
33
```shell
32
34
plonecli add controlpanel
33
35
```
34
36
35
37
This creates the control panel Python file in the control panel's folder where you can define your control panel schema fields.
38
+
It also goes through all the following steps to create a control panel.
36
39
37
40
38
-
### Manual
41
+
##Steps to create a control panel
39
42
40
-
To manually create a control panel, go through the following steps.
43
+
Whether performed automatically with `plonecli` or manually, the following steps are required to create a control panel.
41
44
42
45
- Define the settings interface and form.
43
46
- Register the control panel view in ZCML.
44
47
- Add the control panel to the Plone control panel listing.
45
48
- Set default values in the registry.
49
+
- Register the control panel in XML.
46
50
47
-
#### Define the settings interface and form
51
+
52
+
### Define the settings interface and form
48
53
49
54
Create a Python module, {file}`mypackage/controlpanel/settings.py`, that defines your control panel's settings interface and form class as follows.
Create a file {file}`mypackage/controlpanel/configure.zcml` with the following content to register the control panel view in ZCML.
92
97
@@ -107,7 +112,7 @@ Create a file {file}`mypackage/controlpanel/configure.zcml` with the following c
107
112
</configure>
108
113
```
109
114
110
-
Make sure to include the above file in your package's main {file}`mypackage/configure.zcml` as shown by the highlighted line below.
115
+
Include the above file in your package's main {file}`mypackage/configure.zcml`, as shown by the highlighted line below.
111
116
112
117
{emphasize-lines="9"}
113
118
```xml
@@ -124,7 +129,8 @@ Make sure to include the above file in your package's main {file}`mypackage/conf
124
129
</configure>
125
130
```
126
131
127
-
#### Add the control panel entry
132
+
133
+
### Add the control panel entry
128
134
129
135
Create a {file}`mypackage/profiles/default/controlpanel.xml` in your package's GenericSetup profile with the following content to add your control panel to the Plone control panel listing.
130
136
@@ -165,7 +171,7 @@ These values correspond to the groups in {guilabel}`Site Setup`.
165
171
: {guilabel}`Advanced`
166
172
167
173
168
-
####Set default values in the registry
174
+
### Set default values in the registry
169
175
170
176
Define default values for your settings in {file}`mypackage/profiles/default/registry.xml`.
171
177
@@ -182,9 +188,9 @@ Define default values for your settings in {file}`mypackage/profiles/default/reg
182
188
```
183
189
184
190
185
-
####Register a control panel
191
+
### Register the control panel
186
192
187
-
To manually register a view as a control panel, add the following registration to your {file}`/profiles/default/controlpanel.xml`.
193
+
To register the view as a control panel, add the following registration to your {file}`/profiles/default/controlpanel.xml`.
188
194
189
195
```xml
190
196
<?xml version="1.0"?>
@@ -207,7 +213,12 @@ To manually register a view as a control panel, add the following registration t
207
213
</object>
208
214
```
209
215
210
-
After you perform the above steps for the manual process, you must restart the Plone site. To stop a running Plone instance, press {kbd}`ctrl-c` in the terminal where Plone is running. To start it again, use the appropriate command based on your installation method:
216
+
217
+
## Load your control panel
218
+
219
+
After performing the above steps, you must restart the Plone site.
220
+
To stop a running Plone instance, press {kbd}`ctrl-c` in the terminal where Plone is running.
221
+
To start it again, use the appropriate command based on your installation method.
211
222
212
223
`````{tab-set}
213
224
@@ -249,6 +260,7 @@ make frontend-start
249
260
250
261
Your control panel should now appear in {guilabel}`Site Setup`.
251
262
263
+
252
264
## Access your settings in code
253
265
254
266
You can access your settings in Python code as follows.
0 commit comments