Previous topic

Plugins

Next topic

Main Built-in

This Page

Plugin Class

class djpcms.plugins.DJPplugin

Base class for Plugins. These classes are used to display contents on a djpcms powered site. The basics:

  • A Plugin is dynamic application.
  • It is rendered within a DJPwrapper and each DJPwrapper displays a plugin.
  • It can define style and javascript to include in the page, in a static way (as a meta property of the class) or in a dynamic way by member functions.
  • It can have parameters to control its behaviour.
virtual

If set to true, the class won’t be registered with the plugin’s dictionary. Default False.

name

Unique name. If not provided the class name will be used. Default None.

description

A short description to display in forms.

form

Form class for editing the plugin parameters. Default None, the plugin has no arguments.

form_withrequest

Equivalent to djpcms.views.appsite.ModelApplication.form_withrequest. If set to True, the request instance is passed to the form constructor. Default is False.

js(**kwargs)

Function which can be used to inject javascript dynamically.

css()

Function which can be used to inject css dynamically.

processargs(kwargs)

You can use this hook to perform pre-processing on plugin parameters if form is set. By default do nothing.

edit_form(djp, **kwargs)

Returns the form used to edit the plugin content. Most plugins don’t need to implement this functions but some do. Check the djpcms.plugins.text.Text for example. By default it returns None.

render(djp, wrapper, prefix, **kwargs)

Render the plugin. It returns a safe string to be included in the HTML page. This is the function plugins need to implement.

  • djp instance of djpcms.views.response.DjpResponse.
  • wrapper DJPwrapper instance which wraps the plugin.
  • prefix a prefix string or None to use for forms within the plugin.
  • kwargs plugin specific key-valued arguments.
save(pform)

Save the form plugin

get_form(djp, args=None, withdata=True)

Return an instance of a form or None. Used to edit the plugin when in editing mode. Usually, there is no need to override this function. If your plugin needs input parameters when editing, simple set the form attribute.