8000 Issue #6342: docs of `text_enabled` · django-cms/django-cms@a6b56a8 · GitHub
[go: up one dir, main page]

Skip to content

Commit a6b56a8

Browse files
jeroenpeters1986evildmp
authored andcommitted
Issue #6342: docs of text_enabled
Issue #6342: Extended the docs of `text_enabled` param for plugins
1 parent 9863ecd commit a6b56a8

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ Contributors (based on gitlog, 537 unique authors):
255255
* Jens Diemer
256256
* JensDiemer
257257
* Jeroen Noten
258+
* Jeroen Peters
258259
* Jessica Tallon
259260
* Jimmy Lam
260261
* Johannes Bornhold

docs/reference/plugins.rst

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,19 @@ CMSPluginBase Attributes and Methods Reference
192192

193193
Default: ``False``
194194

195-
Not all plugins are usable in text plugins. If your plugin *is* usable in a text plugin:
195+
This attribute controls whether your plugin will be usable (and rendered)
196+
in a text plugin. When you edit a text plugin on a page, the plugin will show up in
197+
the *CMS Plugins* dropdown and can be configured and inserted. The output will even
198+
be previewed in the text editor.
199+
200+
Of course, not all plugins are usable in text plugins. Therefore the default of this
201+
attribute is ``False``. If your plugin *is* usable in a text plugin:
196202

197203
* set this to ``True``
198-
* make sure your plugin provides its own :meth:`icon_src`
204+
* make sure your plugin provides its own :meth:`icon_alt`, this will be used as a tooltip in
205+
the text-editor and comes in handy when you use multiple plugins in your text.
199206

200-
See also: :attr:`icon_src`, :attr:`icon_alt`.
207+
See also: :meth:`icon_alt`, :meth:`icon_src`.
201208

202209

203210
**Methods**
@@ -326,18 +333,16 @@ CMSPluginBase Attributes and Methods Reference
326333

327334
.. method:: icon_alt()
328335

329-
Although it is optional, authors of "text enabled" plugins should consider
330-
overriding this function as well.
336+
By default :meth:`icon_alt` will return a string of the form: "[plugin type] -
337+
[instance]", but can be modified to return anything you like.
331338

332339
This function accepts the ``instance`` as a parameter and returns a string to be
333-
used as the ``alt`` text for the plugin's icon which will appear as a tooltip in
334-
most browsers. This is useful, because if the same plugin is used multiple
335-
times within the same text plugin, they will typically all render with the
336-
same icon rendering them visually identical to one another. This ``alt`` text and
337-
related tooltip will help the operator distinguish one from the others.
340+
used as the ``alt`` text for the plugin's preview or icon.
338341

339-
By default :meth:`icon_alt` will return a string of the form: "[plugin type] -
340-
[instance]", but can be modified to return anything you like.
342+
Authors of text-enabled plugins should consider overriding this function as
343+
it will be rendered as a tooltip in most browser. This is useful, because if
344+
the same plugin is used multiple times, this tooltip can provide information about
345+
its configuration.
341346

342347
:meth:`icon_alt` takes 1 argument:
343348

@@ -348,7 +353,7 @@ CMSPluginBase Attributes and Methods Reference
348353
def icon_alt(self, instance):
349354
return "%s - %s" % (force_text(self.name), force_text(instance))
350355

351-
See also: :attr:`text_enabled`, :attr:`icon_src`.
356+
See also: :attr:`text_enabled`, :meth:`icon_src`.
352357

353358

354359
.. method:: icon_src(instance)
@@ -361,6 +366,9 @@ CMSPluginBase Attributes and Methods Reference
361366
``True`` to return the path to an icon to display in the text of the text
362367
plugin.
363368

369+
Since djangocms-text-ckeditor introduced inline previews of plugins, the icon
370+
will not be rendered anymore.
371+
364372
icon_src takes 1 argument:
365373

366374
* ``instance``: The instance of the plugin model
@@ -388,8 +396,6 @@ CMSPluginBase Attributes and Methods Reference
388396
:class:`django.template.Context`, which will be used as context to render the
389397
plugin template.
390398

391-
.. versionadded:: 2.4
392-
393399
By default this method will add ``instance`` and ``placeholder`` to the
394400
context, which means for simple plugins, there is no need to overwrite this
395401
method.

0 commit comments

Comments
 (0)
0