@@ -126,6 +126,58 @@ functionality of your plugin. These mixins are:
126
126
* **Title **: Adds an optional title to the plugin which can be used to display
127
127
a title above the plugin or just to simplify the navigation of the plugin tree.
128
128
129
+ Each mixin comes in two flavours, one for the plugin and one for the plugin form.
130
+ The plugin mixin is used to add the functionality to the plugin, while the form
131
+ mixin is used to add their fields to the plugin form. The mixins are
132
+ designed to be used together.
129
133
134
+ For example, if you want to use the attributes mixin, you need to add the
135
+ ``AttributesMixin `` to your plugin and the ``AttributesMixinForm `` to your
136
+ plugin form::
130
137
138
+ from djangocms_frontend.cms_plugins import AttributesMixin, AttributesMixinForm
131
139
140
+ class YourPlugin(AttributesMixin, CMSUIPlugin):
141
+ ...
142
+
143
+ class YourPluginForm(AttributesMixinForm, EntangledModelForm):
144
+ ...
145
+
146
+ Re-using links and images
147
+ -------------------------
148
+
149
+ django CMS Frontend comes with a set of classes that can be used to re-use links
150
+ and images in your plugin. These mixins are:
151
+
152
+ * **LinkPluginMixin **: Adds a link to the plugin. The link can be used to link
153
+ the plugin to a page, a file or an external URL. Include **GetLinkMixin ** with
154
+ your plugin model and base the admin form on **AbstractLinkForm ** (can also
155
+ be used as a mixin)::
156
+
157
+ from djangocms_frontend.contrib.link.cms_plugins import LinkPluginMixin
158
+ from djangocms_frontend.contrib.link.models import GetLinkMixin
159
+ from djangocms_frontend.contrib.link.forms import AbstractLinkForm
160
+
161
+ class YourPlugin(LinkPluginMixin, CMSUIPlugin):
162
+ ...
163
+
164
+ class YourPluginForm(AbstractLinkForm):
165
+ link_is_optional = False # True, if the link is optional
166
+ ...
167
+
168
+ class YourPluginModel(GetLinkMixin, FrontendUIItem):
169
+ ...
170
+
171
+
172
+ * **ImageMixin **: Adds an image to the plugin *model *. Base your plugin form on
173
+ **ImageForm ** (can also be used as a mixin)::
174
+
175
+ from djangocms_frontend.contrib.image.models import ImageMixin
176
+ from djangocms_frontend.contrib.image.forms import ImageForm
177
+
178
+ class YourPluginForm(ImageForm):
179
+ ...
180
+
181
+ class YourPluginModel(ImageMixin, FrontendUIItem):
182
+ image_field = "image" # The name of the image field in the config JSON
183
+ ...
0 commit comments