Skip to content

Commit 7518b42

Browse files
committed
Update docs, add empty children messages
1 parent 89843f4 commit 7518b42

File tree

9 files changed

+188
-23
lines changed

9 files changed

+188
-23
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
{% load cms_tags %}
1+
{% load cms_tags frontend %}
22
<{{ instance.tag_type }}{{ instance.get_attributes }} id="parent-{{ instance.pk|safe }}">
33
{% for plugin in instance.child_plugin_instances %}
44
{% with parentloop=forloop parent=instance %}{% render_plugin plugin %}{% endwith %}
5+
{% empty %}{% user_message _("Add accordion items here") %}
56
{% endfor %}
67
</{{ instance.tag_type }}>

djangocms_frontend/contrib/accordion/templates/djangocms_frontend/bootstrap5/accordion_item.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% load cms_tags %}
1+
{% load cms_tags frontend %}
22
{% spaceless %}
33
<div class="accordion-item">
44
<{{ parent.accordion_header_type|default:"h2" }} class="accordion-header"
@@ -15,6 +15,7 @@
1515
{% with parent=instance %}
1616
{% for plugin in instance.child_plugin_instances %}
1717
{% with forloop as parentloop %}{% render_plugin plugin %}{% endwith %}
18+
{% empty %}{% user_message _("Add content here") %}
1819
{% endfor %}
1920
{% endwith %}{% spaceless %}
2021
</div>

djangocms_frontend/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
],
7373
)
7474

75+
SHOW_EMPTY_CHILDREN = getattr(django_settings, "DJANGOCMS_FRONTEND_SHOW_EMPTY_CHILDREN", False)
76+
7577
FORM_OPTIONS = getattr(django_settings, "DJANGOCMS_FRONTEND_FORM_OPTIONS", {})
7678

7779

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
{% load cms_tags %}<{{ instance.tag_type }}{{ instance.get_attributes }}>
1+
{% load cms_tags frontend %}<{{ instance.tag_type }}{{ instance.get_attributes }}>
22
{% for plugin in instance.child_plugin_instances %}
33
{% with parentloop=forloop parent=instance %}{% render_plugin plugin %}{% endwith %}
4-
{% empty %}{{ instance.simple_content }}{% endfor %}
4+
{% empty %}
5+
{% if instance.simple_content %}{{ instance.simple_content }}{% else %}{% user_message _("Add content here") %}{% endif %}
6+
{% endfor %}
57
</{{ instance.tag_type }}>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% if message %}
2+
<div class="text-center text-black-50 p-5">
3+
<i>{{ message }}</i>
4+
</div>
5+
{% endif %}

djangocms_frontend/templatetags/frontend.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ def framework_info(context, item, as_json=True):
103103
)
104104

105105

106+
@register.inclusion_tag("djangocms_frontend/user_message.html", takes_context=True)
107+
def user_message(context, message):
108+
"""Renders a user message"""
109+
toolbar = getattr(context.get("request", None), "toolbar", None)
110+
if settings.SHOW_EMPTY_CHILDREN and toolbar.edit_mode_active:
111+
return {"message": message}
112+
return {}
113+
114+
106115
class DummyPlugin:
107116
def __init__(self, nodelist):
108117
self.nodelist = nodelist

docs/source/components.rst

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,51 @@ specified using the ``DJANGOCMS_FRONTEND_CAROUSEL_TEMPLATES`` setting.
249249
specified the child plugins add to the caption. If no image is specified
250250
the child plugins make up the slide.
251251

252+
Re-usable component example
253+
===========================
254+
255+
**djangocms-frontend** plugins can be used as components. They can be
256+
used in all your project's templates. Example (if key word arguments are
257+
skipped they fall back to their defaults):
258+
259+
.. code-block::
260+
261+
{% load frontend %}
262+
{% plugin "carousel" template="my_template" carousel_controls=True %}
263+
{% plugin "carouselslide" %}
264+
<h4>Carousel slide title</h4>
265+
<p> Some more content...</p>
266+
{% endplugin %}
267+
{% plugin "carouselslide" %}
268+
<h4>Carousel slide title</h4>
269+
<p> Some more content...</p>
270+
{% endplugin %}
271+
{% endplugin %}
272+
273+
Parameters for ``{% plugin "carousel" %}`` are:
274+
275+
* ``template``: The template to use for the carousel. If not specified the
276+
default template is used.
277+
* ``carousel_controls``: If set to ``True`` the carousel will have controls.
278+
* ``carousel_indicators``: If set to ``True`` the carousel will have indicators.
279+
* ``carousel_interval``: The interval in milliseconds between slides. If not
280+
specified the default interval (5000) is used.
281+
* ``carousel_pause``: If set to ``hover`` the carousel will pause on hover.
282+
* ``carousel_wrap``: If set to ``True`` the carousel will wrap around.
283+
* ``carousel_keyboard``: If set to ``True`` the carousel will react to keyboard
284+
events.
285+
* ``carousel_ride``: If set to ``True`` the carousel will start sliding
286+
automatically.
287+
* ``carousel_aspect_ratio``: The aspect ratio of the carousel. If not specified
288+
the default aspect ratio (16:9) is used.
289+
290+
Parameters for ``{% plugin "carouselslide" %}`` are:
291+
292+
* ``carousel_image``: The image to display in the slide. If not specified the
293+
slide will be empty.
294+
* ``carousel_content``: The HTML caption to display in the slide.
295+
296+
252297
******************
253298
Collapse component
254299
******************
@@ -260,6 +305,7 @@ button) to reveal itself.
260305
Compared to the accordion component the collapse component often is more
261306
flexible but also requires more detailed styling.
262307

308+
263309
.. index::
264310
single: Jumbotron
265311

@@ -484,6 +530,46 @@ Tabs component
484530
``DJANGOCMS_FRONTEND_TAB_EFFECTS`` setting.
485531

486532

533+
Re-usable component example
534+
===========================
535+
536+
**djangocms-frontend** plugins can be used as components. They can be
537+
used in all your project's templates. Example (if key word arguments are
538+
skipped they fall back to their defaults):
539+
540+
.. code-block::
541+
542+
{% load frontend %}
543+
{% plugin "tab" template="my_template" tab_type="nav-pills" tab_align="justify-content-center" %}
544+
{% plugin "tabitem" tab_title="Tab 1" tab_bordered=True %}
545+
<h4>Content of tab 1</h4>
546+
<p> Some content...</p>
547+
{% endplugin %}
548+
{% plugin "tabitem" tab_title="Tab 2" tab_bordered=True %}
549+
<h4>Content of tab 2</h4>
550+
<p> Some more content...</p>
551+
{% endplugin %}
552+
{% endplugin %}
553+
554+
555+
Parameters for ``{% plugin "tab" %}`` are:
556+
557+
* ``template``: The template to use for the tabs. If not specified the default
558+
template is used.
559+
* ``tab_type``: The type of the tabs. If not specified the default type is used.
560+
* ``tab_align``: The alignment of the tabs. If not specified the default alignment
561+
is used.
562+
* ``tab_index``: The index of the initially active tab. If not specified the
563+
first tab is active.
564+
* ``tab_effect``: The effect of the tabs. ``"fade"`` is available. If not
565+
specified no effect is used.
566+
567+
Parameters for ``{% plugin "tabitem" %}`` are:
568+
569+
* ``tab_title``: The title of the tab.
570+
* ``tab_bordered``: If set to ``True`` the tab will have a border.
571+
572+
487573
.. index::
488574
single: Icon
489575

docs/source/grid.rst

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,57 @@ content.
112112
Removed:
113113
The column type entry has been removed since it was a legacy from
114114
Bootstrap version 3.
115+
116+
***************************
117+
Re-usable component example
118+
***************************
119+
120+
**djangocms-frontend** plugins can be used as components. They can be
121+
used in all your project's templates. Example (if key word arguments are
122+
skipped they fall back to their defaults):
123+
124+
.. code-block::
125+
126+
{% load frontend %}
127+
{% plugin "gridcontainer" container_type="container-fluid" %}
128+
{% plugin "row" vertical_alignment="align-items-center" %}
129+
{% plugin "gridcolumn" xs_col=12 md_col=6 text_alignment="center" %}
130+
This content is inside a column.
131+
{% endplugin %}
132+
{% plugin "gridcolumn" xs_col=12 md_col=6 text_alignment="center" %}
133+
This content is inside another column.
134+
{% endplugin %}
135+
{% endplugin %}
136+
This content still is inside a container.
137+
{% endplugin %}
138+
139+
Parameters for ``{% plugin "gridcontainer" %}`` are:
140+
141+
* ``container_type``: The type of container. Default is ``container``. Other
142+
options are ``container-fluid`` and ``container-full``.
143+
144+
Parameters for ``{% plugin "gridrow" %}`` are:
145+
146+
* ``vertical_alignment``: The vertical alignment of the row. Default is
147+
``align-items-start``. Other options are ``align-items-center`` and
148+
``align-items-end``.
149+
* ``horizontal_alignment``: The horizontal alignment of the row. Default is
150+
``justify-content-start``. Other options are ``justify-content-center``,
151+
``justify-content-end`` and ``justify-content-around``.
152+
* ``gutters``: Size of gutter between columns. Default is ``3``. Other
153+
options are ``0``, ``1``, ``2``, ``4``, ``5``.
154+
* ``row_cols_xs``: Number of columns on mobile devices.
155+
* ``row_cols{sm|md|lg|xl|xx}``: Number of columns on larger devices.
156+
157+
158+
Parameters for ``{% plugin "gridcolumn" %}`` are:
159+
* ``column_alignment``: The vertical alignment of the column. Default is
160+
``align-self-start``. Other options are ``align-self-center`` and
161+
``align-self-end``.
162+
* ``text_alignment``: The text alignment of the column. Options are
163+
``left``, ``center`` and ``right``.
164+
* ``xs_col``: Number of columns on mobile devices.
165+
* ``{sm|md|lg|xl|xx}_col``: Number of columns on larger devices.
166+
167+
168+

docs/source/reference.rst

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
###########
2-
Reference
3-
###########
1+
#########
2+
Reference
3+
#########
44

5-
**********
6-
Settings
7-
**********
5+
********
6+
Settings
7+
********
88

99
**djangocms-frontend** can be configured by putting the appropriate settings
1010
in your project's ``settings.py``.
@@ -319,6 +319,15 @@ in your project's ``settings.py``.
319319

320320
This lost of options define the icon size choices a user can select. The values (first tuple element) are css units for the ``font-size`` css property. Besides relative units (``%``) any css unit can be used, e.g. ``112pt``.
321321

322+
.. py:attribute:: settings.DJANGOCMS_FRONTEND_SHOW_EMPTY_CHILDREN
323+
324+
Default: ``False``
325+
326+
If set to ``True`` the frontend editing will show a message where children
327+
can be added to plugins to complete the design. This is supposed to make
328+
the editing experience more intuitive for editors.
329+
330+
322331
******
323332
Models
324333
******
@@ -393,9 +402,9 @@ Models
393402
returns a plugin-specific short description shown in the structure mode
394403
of django CMS.
395404

396-
**************
397-
Form widgets
398-
**************
405+
************
406+
Form widgets
407+
************
399408

400409
**djangocms-frontend** contains button group widgets which can be used as
401410
for ``forms.ChoiceField``. They might turn out helpful when adding custom
@@ -449,13 +458,9 @@ plugins.
449458
This form field is identical to the ``OptionalDeviceChoiceField`` above,
450459
but requires the user to select at least one device.
451460

452-
453-
454-
455-
456-
*********************
457-
Management commands
458-
*********************
461+
*******************
462+
Management commands
463+
*******************
459464

460465
Management commands are run by typing ``./manage.py frontend command`` in the
461466
project directory. ``command`` can be one of the following:
@@ -484,9 +489,9 @@ project directory. ``command`` can be one of the following:
484489
then syncing the new permission with these commands.
485490

486491

487-
***************
488-
Running Tests
489-
***************
492+
*************
493+
Running Tests
494+
*************
490495

491496
You can run tests by executing:
492497

0 commit comments

Comments
 (0)