@@ -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",
@@ -62,12 +63,6 @@ Add the following entries to your ``INSTALLED_APPS``:
6263 "djangocms_frontend.contrib.tabs",
6364 "djangocms_frontend.contrib.utilities",
6465
65- .. note :: Using Django 2.2 to 3.1
66-
67- You will need to add ``django-jsonfield-backport`` to your
68- ``requirements.txt`` and add ``"django_jsonfield_backport"`` to your
69- ``INSTALLED_APPS``.
70-
7166
7267 Create necessary database table
7368===============================
@@ -440,15 +435,19 @@ the upper right corner:
440435Using frontend plugins as components in templates
441436=================================================
442437
438+ .. versionadded :: 2.0
439+
443440The plugins of **djangocms-frontend ** can be used as components in your
444441templates - even in apps that do not use or integrate with djanog CMS
445442otherwise. This is useful if you want use exactly the same markup for, say,
446443buttons, links, the grid both in pages managed with django CMS and in
447- other parts of your project.
444+ other parts of your project without duplicating HTML code .
448445
449- This allows you to keep one set of templates for your django CMS frontend
450- plugins and any changes to those templates will be reflected in all parts
451- of your project.
446+ This feature introduces a simple and flexible way to re-use djangocms-frontend
447+ plugins directly in templates without needing to create database entries for
448+ them. This allows developers to maintain clean, reusable, and dynamic
449+ components, such as buttons, cards, links, and more, while minimizing code
450+ repetition.
452451
453452To use a frontend plugin in a template you need to load the ``frontend `` tags
454453and then use the ``plugin `` template tag to render a frontend plugin.
@@ -464,15 +463,48 @@ The plugins will be rendered based on their standard attribute settings.
464463You can override these settings by passing them as keyword arguments to the
465464``plugin `` template tag.
466465
467- See the documentation of the djanog CMS plugins for examples of how to use
468- the ``{% plugin %} `` template tag with each plugin.
466+ You can also create more complex reusable components, like a card with inner
467+ elements such as headers, bodies, and lists, by nesting plugins. Here’s an
468+ example of a card component::
469+
470+ {% load frontend %}
471+ {% plugin "card" card_alignment="center" card_outline="info" card_text_color="primary" card_full_height=True %}
472+ {% plugin "cardinner" inner_type="card-header" text_alignment="start" %}
473+ <h4>Card title</h4>
474+ {% endplugin %}
475+ {% plugin "cardinner" inner_type="card-body" text_alignment="center" %}
476+ Some quick example text to build on the card title and make up the bulk of the card's content.
477+ {% endplugin %}
478+ {% plugin "listgroupitem" %}An item{% endplugin %}
479+ {% plugin "listgroupitem" %}A second item{% endplugin %}
480+ {% plugin "listgroupitem" %}A third item{% endplugin %}
481+ {% endplugin %}
482+
483+ Breakdown of the Code:
484+
485+ * ``plugin "card" ``: Creates the outer card component.
486+ * ``card_alignment="center" ``: Aligns the card content to the center.
487+ * ``card_outline="info" ``: Gives the card an "info" outline style.
488+ * ``card_text_color="primary" ``: Changes the text color to "primary."
489+ * ``card_full_height=True ``: Ensures the card takes up the full height of its container.
490+ * Nested ``plugin "cardinner" ``: Creates inner components within the card.
491+ * ``inner_type="card-header" ``: Specifies a header section for the card.
492+ * ``text_alignment="start" ``: Aligns the header text to the start (left).
493+ * Additional nested ``plugin "cardinner" `` and ``listgroupitem ``:
494+ * These create the body of the card and a list group inside the card.
495+
496+ The above template generates a dynamic card component with a header, a body,
497+ and a list group that can be reused across multiple pages without requiring
498+ database entries.
499+
500+ For more examples, see the documentation of the djanog CMS plugins on of how to
501+ use the ``{% plugin %} `` template tag with each plugin.
502+
469503
470504.. note ::
471505
472506 While this is designed for **djangocms-frontend ** plugins primarily, it
473- will work with most django CMS plugins.
507+ will work with many other django CMS plugins.
474508
475509 Since no plugins are created in the database, plugins relying on their
476510 instances being available in the database will potentially not work.
477- This especially is true for plugins that have a foreign key to
478- other models.
0 commit comments