Models¶
djangocms-frontend subclasses the CMSPlugin model.
- class FrontendUIItem(CMSPlugin)¶
Import from
djangocms_frontend.models.All concrete models for UI items are proxy models of this class. This implies you can create, delete and update instances of the proxy models and all the data will be saved as if you were using this original (non-proxied) model.
This way all proxies can have different python methods as needed while still all using the single database table of
FrontendUIItem.
- FrontendUIItem.ui_item¶
This CharField contains the UI item’s type without the suffix “Plugin”, e.g. “Link” and not “LinkPlugin”. This is a convenience field. The plugin type is determined by
CMSPlugin.plugin_type.
- FrontendUIItem.tag_type¶
This is the tag type field determining what tag type the UI item should have. Tag types default to
<div>.
- FrontendUIItem.config¶
The field
configis the JSON field that contains a dictionary with all specific information needed for the UI item. The entries of the dictionary can be directly read as attributes of theFrontendUIIteminstance. For example,ui_item.contextwill giveui_item.config["context"].Warning
Note that changes to the
configmust be written directly to the dictionary:ui_item.config["context"] = None.
- FrontendUIItem.add_classes(self, *args)¶
This helper method allows a Plugin’s render method to add framework-specific html classes to be added when a model is rendered. Each positional argument can be a string for a class name or a list of strings to be added to the list of html classes.
These classes are not saved to the database. They merely a are stored to simplify the rendering process and are lost once a UI item has been rendered.
- FrontendUIItem.get_attributes(self)¶
This method renders all attributes given in the optional
attributesfield (stored in.config). Theclassattribute reflects all additional classes that have been passed to the model instance by means of the.add_classesmethod.
- FrontendUIItem.initialize_from_form(self, form)¶
Since the UIItem models do not have default values for the contents of their
.configdictionary, a newly created instance of an UI item will not have config data set, not even required data.This method initializes all fields in
.configby setting the value to the respectiveinitialproperty of the UI items admin form.
- FrontendUIItem.get_short_description(self)¶
returns a plugin-specific short description shown in the structure mode of django CMS.