Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Clarify how to re-use image and links in custom plugins #176

Merged
merged 23 commits into from
Jan 9, 2024
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4245adc
Fix: Update locales and add floating options for images
fsbraun Nov 7, 2023
e66e618
Merge branch 'master' of github.com:fsbraun/djangocms-frontend
fsbraun Nov 7, 2023
cbaccdd
Merge branch 'master' of github.com:fsbraun/djangocms-frontend
fsbraun Nov 28, 2023
66e053e
fix: icons not showing in ckeditor
fsbraun Nov 28, 2023
fec0ece
Merge branch 'django-cms:master' into master
fsbraun Nov 28, 2023
49e4acc
Merge branch 'django-cms:master' into master
fsbraun Nov 28, 2023
a9ead97
Add image drag and drop
fsbraun Nov 28, 2023
9ac7126
Merge branch 'master' of github.com:fsbraun/djangocms-frontend
fsbraun Nov 28, 2023
f5f27b6
Update docs
fsbraun Nov 28, 2023
6d5fac4
Add tests
fsbraun Nov 28, 2023
18d60ab
Fix tests for v4
fsbraun Nov 28, 2023
44d5035
Bump version
fsbraun Nov 28, 2023
210cccd
Update changelog
fsbraun Nov 28, 2023
510494e
Merge branch 'django-cms:master' into master
fsbraun Nov 28, 2023
297d436
Merge branch 'django-cms:master' into master
fsbraun Dec 13, 2023
fc20a5a
Merge branch 'django-cms:master' into master
fsbraun Dec 15, 2023
606cc91
fix/remove-unused-css
fsbraun Dec 15, 2023
1af2ef9
Merge branch 'django-cms:master' into master
fsbraun Jan 4, 2024
60f810f
Merge branch 'django-cms:master' into master
fsbraun Jan 8, 2024
05a0939
Merge branch 'django-cms:master' into master
fsbraun Jan 8, 2024
a8e5f2d
Doc typos
fsbraun Jan 8, 2024
6e6b3fc
Update docs on how to reuse link or image
fsbraun Jan 9, 2024
75d2b78
Merge branch 'master' into doc/reusing-link-image
fsbraun Jan 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions docs/source/how-to/add-frontend-plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,58 @@ functionality of your plugin. These mixins are:
* **Title**: Adds an optional title to the plugin which can be used to display
a title above the plugin or just to simplify the navigation of the plugin tree.

Each mixin comes in two flavours, one for the plugin and one for the plugin form.
The plugin mixin is used to add the functionality to the plugin, while the form
mixin is used to add their fields to the plugin form. The mixins are
designed to be used together.

For example, if you want to use the attributes mixin, you need to add the
``AttributesMixin`` to your plugin and the ``AttributesMixinForm`` to your
plugin form::

from djangocms_frontend.cms_plugins import AttributesMixin, AttributesMixinForm

class YourPlugin(AttributesMixin, CMSUIPlugin):
...

class YourPluginForm(AttributesMixinForm, EntangledModelForm):
...

Re-using links and images
-------------------------

django CMS Frontend comes with a set of classes that can be used to re-use links
and images in your plugin. These mixins are:

* **LinkPluginMixin**: Adds a link to the plugin. The link can be used to link
the plugin to a page, a file or an external URL. Include **GetLinkMixin** with
your plugin model and base the admin form on **AbstractLinkForm** (can also
be used as a mixin)::

from djangocms_frontend.contrib.link.cms_plugins import LinkPluginMixin
from djangocms_frontend.contrib.link.models import GetLinkMixin
from djangocms_frontend.contrib.link.forms import AbstractLinkForm

class YourPlugin(LinkPluginMixin, CMSUIPlugin):
...

class YourPluginForm(AbstractLinkForm):
link_is_optional = False # True, if the link is optional
...

class YourPluginModel(GetLinkMixin, FrontendUIItem):
...


* **ImageMixin**: Adds an image to the plugin *model*. Base your plugin form on
**ImageForm** (can also be used as a mixin)::

from djangocms_frontend.contrib.image.models import ImageMixin
from djangocms_frontend.contrib.image.forms import ImageForm

class YourPluginForm(ImageForm):
...

class YourPluginModel(ImageMixin, FrontendUIItem):
image_field = "image" # The name of the image field in the config JSON
...