Skip to content

Commit 2d6b0e8

Browse files
authored
Merge branch 'master' into master
2 parents cac6683 + 4271029 commit 2d6b0e8

File tree

10 files changed

+83
-23
lines changed

10 files changed

+83
-23
lines changed

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
python-version: '3.11'
2020
cache: 'pip'
2121
- name: Cache dependencies
22-
uses: actions/[email protected].0
22+
uses: actions/[email protected].1
2323
with:
2424
path: ~/.cache/pip
2525
key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.in') }}
@@ -44,7 +44,7 @@ jobs:
4444
python-version: '3.11'
4545
cache: 'pip'
4646
- name: Cache dependencies
47-
uses: actions/[email protected].0
47+
uses: actions/[email protected].1
4848
with:
4949
path: ~/.cache/pip
5050
key: ${{ runner.os }}-pip-${{ hashFiles('docs/requirements.in') }}

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ For a manual install:
115115

116116
- run ``pip install djangocms-frontend``
117117

118-
- add the following entries to your ``INSTALLED_APPS``:
118+
- add the following entries to your ``INSTALLED_APPS`` (or only those you need):
119119

120120
.. code::
121121
@@ -127,6 +127,7 @@ For a manual install:
127127
'djangocms_frontend.contrib.card',
128128
'djangocms_frontend.contrib.carousel',
129129
'djangocms_frontend.contrib.collapse',
130+
'djangocms_frontend.contrib.component',
130131
'djangocms_frontend.contrib.content',
131132
'djangocms_frontend.contrib.grid',
132133
'djangocms_frontend.contrib.icon',

djangocms_frontend/contrib/collapse/templates/djangocms_frontend/bootstrap5/collapse-container.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<{{ instance.tag_type }}{{ instance.get_attributes }}
33
id="{{ instance.container_identifier }}"
44
role="tabpanel"
5-
data-bs-parent="#parent-{{ parent.pk|safe }}"
5+
data-bs-parent="#{{ parent.uuid }}"
66
aria-labelledby="trigger-{{ instance.container_identifier }}">
77
{% for plugin in instance.child_plugin_instances %}
88
{% with forloop as parentloop %}{% render_plugin plugin %}{% endwith %}

djangocms_frontend/contrib/collapse/templates/djangocms_frontend/bootstrap5/collapse.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% load cms_tags frontend %}
22
<{{ instance.tag_type }}{{ instance.get_attributes }}
3-
id="parent-{{ instance.pk|safe }}"
3+
id="{{ instance.uuid }}"
44
data-bs-children="{{ instance.collapse_siblings }}"
55
role="tablist"
66
>

djangocms_frontend/contrib/content/cms_plugins.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class BlockquotePlugin(
7777
),
7878
]
7979

80+
frontend_editable_fields = ("quote_content", "quote_origin")
81+
8082

8183
@plugin_pool.register_plugin
8284
class FigurePlugin(
@@ -110,3 +112,5 @@ class FigurePlugin(
110112
},
111113
),
112114
]
115+
116+
frontend_editable_fields = ("figure_caption",)

djangocms_frontend/contrib/content/templates/djangocms_frontend/bootstrap5/blockquote.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
{# djlint:on #}
1010
{% for plugin in instance.child_plugin_instances %}
1111
{% with parentloop=forloop parent=instance %}{% render_plugin plugin %}{% endwith %}
12-
{% empty %}{{ instance.quote_content|html_safe }}{% endfor %}
12+
{% empty %}{% inline_field instance "quote_content" "" "html_safe" %}{% endfor %}
1313
{# djlint:off #}
1414
</blockquote>
1515
{# djlint:on #}
1616
{% if instance.quote_origin %}
1717
<figcaption class="blockquote-footer">
18-
{{ instance.quote_origin|safe_caption }}
18+
{% inline_field instance "quote_origin" "" "safe_caption" %}
1919
</figcaption>
2020
</figure>
2121
{% endif %}

djangocms_frontend/contrib/content/templates/djangocms_frontend/bootstrap5/figure.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
{% for plugin in instance.child_plugin_instances %}
44
{% with forloop=parentloop parent=instance %}{% render_plugin plugin %}{% endwith %}
55
{% endfor %}
6-
<figcaption class="figure-caption{% if figure_alignment %} text-{{ figure_alignment }}{% endif %}">{{ instance.figure_caption|safe_caption }}</figcaption>
6+
<figcaption class="figure-caption{% if figure_alignment %} text-{{ figure_alignment }}{% endif %}">{% inline_field instance "figure_caption" "" "safe_caption" %}</figcaption>
77
</figure>

docs/source/custom_components.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Custom Components
55
#################
66

7+
.. versionadded:: 2.0
8+
79
Some frontend developers prefer custom components specifically tailored to
810
give the project a unique and distinct look.
911

docs/source/getting_started.rst

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Add the following entries to your ``INSTALLED_APPS``:
5151
"djangocms_frontend.contrib.card",
5252
"djangocms_frontend.contrib.carousel",
5353
"djangocms_frontend.contrib.collapse",
54+
"djangocms_frontend.contrib.component",
5455
"djangocms_frontend.contrib.content",
5556
"djangocms_frontend.contrib.grid",
5657
"djangocms_frontend.contrib.icon",
@@ -63,12 +64,6 @@ Add the following entries to your ``INSTALLED_APPS``:
6364
"djangocms_frontend.contrib.tabs",
6465
"djangocms_frontend.contrib.utilities",
6566
66-
.. note :: Using Django 2.2 to 3.1
67-
68-
You will need to add ``django-jsonfield-backport`` to your
69-
``requirements.txt`` and add ``"django_jsonfield_backport"`` to your
70-
``INSTALLED_APPS``.
71-
7267
7368
Create necessary database table
7469
===============================
@@ -441,15 +436,19 @@ the upper right corner:
441436
Using frontend plugins as components in templates
442437
=================================================
443438

439+
.. versionadded:: 2.0
440+
444441
The plugins of **djangocms-frontend** can be used as components in your
445442
templates - even in apps that do not use or integrate with djanog CMS
446443
otherwise. This is useful if you want use exactly the same markup for, say,
447444
buttons, links, the grid both in pages managed with django CMS and in
448-
other parts of your project.
445+
other parts of your project without duplicating HTML code.
449446

450-
This allows you to keep one set of templates for your django CMS frontend
451-
plugins and any changes to those templates will be reflected in all parts
452-
of your project.
447+
This feature introduces a simple and flexible way to re-use djangocms-frontend
448+
plugins directly in templates without needing to create database entries for
449+
them. This allows developers to maintain clean, reusable, and dynamic
450+
components, such as buttons, cards, links, and more, while minimizing code
451+
repetition.
453452

454453
To use a frontend plugin in a template you need to load the ``frontend`` tags
455454
and then use the ``plugin`` template tag to render a frontend plugin.
@@ -465,15 +464,48 @@ The plugins will be rendered based on their standard attribute settings.
465464
You can override these settings by passing them as keyword arguments to the
466465
``plugin`` template tag.
467466

468-
See the documentation of the djanog CMS plugins for examples of how to use
469-
the ``{% plugin %}`` template tag with each plugin.
467+
You can also create more complex reusable components, like a card with inner
468+
elements such as headers, bodies, and lists, by nesting plugins. Here’s an
469+
example of a card component::
470+
471+
{% load frontend %}
472+
{% plugin "card" card_alignment="center" card_outline="info" card_text_color="primary" card_full_height=True %}
473+
{% plugin "cardinner" inner_type="card-header" text_alignment="start" %}
474+
<h4>Card title</h4>
475+
{% endplugin %}
476+
{% plugin "cardinner" inner_type="card-body" text_alignment="center" %}
477+
Some quick example text to build on the card title and make up the bulk of the card's content.
478+
{% endplugin %}
479+
{% plugin "listgroupitem" %}An item{% endplugin %}
480+
{% plugin "listgroupitem" %}A second item{% endplugin %}
481+
{% plugin "listgroupitem" %}A third item{% endplugin %}
482+
{% endplugin %}
483+
484+
Breakdown of the Code:
485+
486+
* ``plugin "card"``: Creates the outer card component.
487+
* ``card_alignment="center"``: Aligns the card content to the center.
488+
* ``card_outline="info"``: Gives the card an "info" outline style.
489+
* ``card_text_color="primary"``: Changes the text color to "primary."
490+
* ``card_full_height=True``: Ensures the card takes up the full height of its container.
491+
* Nested ``plugin "cardinner"``: Creates inner components within the card.
492+
* ``inner_type="card-header"``: Specifies a header section for the card.
493+
* ``text_alignment="start"``: Aligns the header text to the start (left).
494+
* Additional nested ``plugin "cardinner"`` and ``listgroupitem``:
495+
* These create the body of the card and a list group inside the card.
496+
497+
The above template generates a dynamic card component with a header, a body,
498+
and a list group that can be reused across multiple pages without requiring
499+
database entries.
500+
501+
For more examples, see the documentation of the djanog CMS plugins on of how to
502+
use the ``{% plugin %}`` template tag with each plugin.
503+
470504

471505
.. note::
472506

473507
While this is designed for **djangocms-frontend** plugins primarily, it
474-
will work with most django CMS plugins.
508+
will work with many other django CMS plugins.
475509

476510
Since no plugins are created in the database, plugins relying on their
477511
instances being available in the database will potentially not work.
478-
This especially is true for plugins that have a foreign key to
479-
other models.

docs/source/grid.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@ Full container
3737
New feature:
3838
Containers can have a background color ("context"), opacity and shadow.
3939

40+
Component example
41+
=================
42+
43+
To create a container in a Django template, you need to load the `frontend` tags
44+
and then use the `plugin` template tag to render the container plugin.
45+
Below is an example of how you might do this::
46+
47+
{% load frontend %}
48+
49+
<!-- Example of using the plugin template tag for a container -->
50+
{% plugin "container" container_type="container-fluid" %}
51+
{% plugin "row" %}
52+
{% plugin "column" xs_col=6 %}
53+
<p>This is the first column inside the container.</p>
54+
{% endplugin %}
55+
{% plugin "column" xs_col=6 %}
56+
<p>This is the second column inside the container.</p>
57+
{% endplugin %}
58+
{% endplugin %}
59+
{% endplugin %}
60+
4061

4162
.. index::
4263
single: Row

0 commit comments

Comments
 (0)