Skip to content

Commit 1138ee5

Browse files
committed
Merge pull request django-cms#2249 from yakky/feature/ph_docs
Fix PlaceholderField documentation
2 parents 06ee009 + 618ecac commit 1138ee5

File tree

1 file changed

+43
-39
lines changed

1 file changed

+43
-39
lines changed

docs/extending_cms/placeholders.rst

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@ Placeholders outside the CMS
44

55
Placeholders are special model fields that django CMS uses to render
66
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.
99

1010
Placeholders can be viewed as containers for :class:`CMSPlugin` instances, and
1111
can be used outside the CMS in custom applications using the
1212
:class:`~cms.models.fields.PlaceholderField`.
1313

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`.
1616

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.
1722

1823
**********
1924
Quickstart
@@ -57,6 +62,8 @@ placeholder (configuration is the same as for placeholders in the CMS) or you ca
5762
Admin Integration
5863
=================
5964

65+
.. versionchanged:: 3.0
66+
6067
If you install this model in the admin application, you have to use
6168
:class:`~cms.admin.placeholderadmin.PlaceholderAdmin` instead of
6269
:class:`~django.contrib.admin.ModelAdmin` so the interface renders
@@ -69,6 +76,14 @@ correctly::
6976
admin.site.register(MyModel, PlaceholderAdmin)
7077

7178

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+
7287
I18N Placeholders
7388
=================
7489

@@ -115,10 +130,15 @@ Now to render the placeholder in a template you use the
115130

116131
{% render_placeholder mymodel_instance.my_placeholder "640" %}
117132

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
122142
:attr:`request <django.http.HttpRequest>` object in the context. This is
123143
typically achieved in Django applications by using :class:`RequestContext`::
124144

@@ -145,36 +165,34 @@ like this:
145165
Adding content to a placeholder
146166
*******************************
147167

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
150169

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
155171
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.
160175

161-
You are now using the so-called *front-end edit mode*:
176+
You are now using the so-called *frontend edit mode*:
162177

163178
|edit-banner|
164179

165180
.. |edit-banner| image:: ../images/edit-banner.png
166181

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.
170186

171187
|frontend-placeholder-add-plugin|
172188

173189
.. |frontend-placeholder-add-plugin| image:: ../images/frontend-placeholder-add-plugin.png
174190

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.
178196

179197
.. _placeholder_object_permissions:
180198

@@ -202,18 +220,4 @@ to current user only on his ``UserProfile`` object::
202220
return False
203221

204222

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-
219223
.. _django-hvad: https://github.com/kristianoellegaard/django-hvad

0 commit comments

Comments
 (0)