@@ -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:
441436Using frontend plugins as components in templates
442437=================================================
443438
439+ .. versionadded :: 2.0
440+
444441The plugins of **djangocms-frontend ** can be used as components in your
445442templates - even in apps that do not use or integrate with djanog CMS
446443otherwise. This is useful if you want use exactly the same markup for, say,
447444buttons, 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
454453To use a frontend plugin in a template you need to load the ``frontend `` tags
455454and 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.
465464You 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.
0 commit comments