@@ -4,16 +4,21 @@ Placeholders outside the CMS
4
4
5
5
Placeholders are special model fields that django CMS uses to render
6
6
user-editable content (plugins) in templates. That is, it's the place where a
7
- user can add text, video or any other plugin to a webpage, using either the
8
- normal Django admin interface or the so called ` frontend editing ` .
7
+ user can add text, video or any other plugin to a webpage, using the same
8
+ ` frontend editing ` as the CMS pages .
9
9
10
10
Placeholders can be viewed as containers for :class: `CMSPlugin ` instances, and
11
11
can be used outside the CMS in custom applications using the
12
12
:class: `~cms.models.fields.PlaceholderField `.
13
13
14
- By defining one (or several) :class: `~cms.models.fields.PlaceholderField ` on a custom model you can take
15
- advantage of the full power of :class: `CMSPlugin `, including frontend editing .
14
+ By defining one (or several) :class: `~cms.models.fields.PlaceholderField ` on a
15
+ custom model you can take advantage of the full power of :class: `CMSPlugin `.
16
16
17
+ .. warning ::
18
+
19
+ Screenshots are not in sync with the 3.0 UI at the moment, they will be
20
+ updated once the new UI will be finalized; for the same reason, you'll find
21
+ minor difference in the UI description.
17
22
18
23
**********
19
24
Quickstart
@@ -57,6 +62,8 @@ placeholder (configuration is the same as for placeholders in the CMS) or you ca
57
62
Admin Integration
58
63
=================
59
64
65
+ .. versionchanged :: 3.0
66
+
60
67
If you install this model in the admin application, you have to use
61
68
:class: `~cms.admin.placeholderadmin.PlaceholderAdmin ` instead of
62
69
:class: `~django.contrib.admin.ModelAdmin ` so the interface renders
@@ -69,6 +76,14 @@ correctly::
69
76
admin.site.register(MyModel, PlaceholderAdmin)
70
77
71
78
79
+ .. warning ::
80
+
81
+ Since 3.0 placeholder content can only be modified from the
82
+ frontend, and thus placeholderfields **must ** not be present in any
83
+ ``fieldsets ``, ``fields ``, ``form `` or other modeladmin fields definition
84
+ attribute.
85
+
86
+
72
87
I18N Placeholders
73
88
=================
74
89
@@ -115,10 +130,15 @@ Now to render the placeholder in a template you use the
115
130
116
131
{% render_placeholder mymodel_instance.my_placeholder "640" %}
117
132
118
- The :ttag: `render_placeholder ` tag takes a
119
- :class: `~cms.models.fields.PlaceholderField ` instance as its first argument and
120
- optionally accepts a width parameter as its second argument for context sensitive
121
- plugins. The view in which you render your placeholder field must return the
133
+ The :ttag: `render_placeholder ` tag takes the following parameters:
134
+
135
+ * :class: `~cms.models.fields.PlaceholderField ` instance
136
+ * ``width `` parameter for context sensitive plugins (optional)
137
+ * ``language `` keyword plus ``language-code `` string to render content in the
138
+ specified language (optional)
139
+
140
+
141
+ The view in which you render your placeholder field must return the
122
142
:attr: `request <django.http.HttpRequest> ` object in the context. This is
123
143
typically achieved in Django applications by using :class: `RequestContext `::
124
144
@@ -145,36 +165,34 @@ like this:
145
165
Adding content to a placeholder
146
166
*******************************
147
167
148
- There are two ways to add or edit content to a placeholder, the front-end admin
149
- view and the back-end view.
168
+ .. versionchanged :: 3.0
150
169
151
- Using the front-end editor
152
- ==========================
153
-
154
- Probably the simplest way to add content to a placeholder, simply visit the
170
+ Placeholders can be edited from the frontend by visiting the
155
171
page displaying your model (where you put the :ttag: `render_placeholder ` tag),
156
- then append ``?edit `` to the page's URL. This will make a top banner appear,
157
- and after switching the "Edit mode" button to "on", the banner will prompt you
158
- for your username and password (the user should be allowed to edit the page,
159
- obviously).
172
+ then append ``?edit `` to the page's URL.
173
+ This will make the frontend editor top banner appear, and will eventually
174
+ require you to login.
160
175
161
- You are now using the so-called *front-end edit mode *:
176
+ You are now using the so-called *frontend edit mode *:
162
177
163
178
|edit-banner |
164
179
165
180
.. |edit-banner | image :: ../images/edit-banner.png
166
181
167
- Once in Front-end editing mode, your placeholders should display a menu,
168
- allowing you to add plugins to them. The following screen shot shows a
169
- default selection of plugins in an empty placeholder.
182
+ Once in Front-end editing mode, switch to **Structure mode **, and you should be
183
+ able to see an outline of the placeholder, and a menu, allowing you to add
184
+ plugins to them. The following screenshot shows a default selection of plugins
185
+ in an empty placeholder.
170
186
171
187
|frontend-placeholder-add-plugin |
172
188
173
189
.. |frontend-placeholder-add-plugin | image :: ../images/frontend-placeholder-add-plugin.png
174
190
175
- Plugins are rendered at once, so you can get an idea how it will look
176
- `in fine `. However, to view the final look of a plugin simply leave edit mode by
177
- clicking the "Edit mode" button in the banner again.
191
+ Adding the plugins automatically update the model content and they are rendered
192
+ in realtime.
193
+
194
+ There is no automatic draft / live version of general Django models, so plugins
195
+ content is updated instantly whenever you add / edit them.
178
196
179
197
.. _placeholder_object_permissions :
180
198
@@ -202,18 +220,4 @@ to current user only on his ``UserProfile`` object::
202
220
return False
203
221
204
222
205
- *********
206
- Fieldsets
207
- *********
208
-
209
- There are some hard restrictions if you want to add custom fieldsets to an
210
- admin page with at least one :class: `~cms.models.fields.PlaceholderField `:
211
-
212
- 1. Every :class: `~cms.models.fields.PlaceholderField ` **must ** be in its own
213
- :attr: `fieldset <django.contrib.admin.ModelAdmin.fieldsets> `, one
214
- :class: `~cms.models.fields.PlaceholderField ` per fieldset.
215
- 2. You **must ** include the following two classes: ``'plugin-holder' `` and
216
- ``'plugin-holder-nopage' ``
217
-
218
-
219
223
.. _django-hvad : https://github.com/kristianoellegaard/django-hvad
0 commit comments