Replies: 3 comments
-
Hello @jrief, |
Beta Was this translation helpful? Give feedback.
-
@fsbraun this was the discussion I was talking about in our biweekly meeting today. |
Beta Was this translation helpful? Give feedback.
-
@jrief I see three parts to your proposal.
Regarding the first part, I just wanted to point out the plugin methods At first sight, I have some concerns regarding part two: The plugin tree is a data structure (in the Django model kingdom) that should not depend on the template context (which belongs to Django's template kingdom). The plugins should be able to respond to context on rendering, but the tree structure might be better off being independent of the context. (A change in context would render an existing plugin tree in the database "illegal" and any change made might not be reversible.) One more thought on the complexity of pasting or moving plugins versus adding single plugins:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Preambel
We should rethink the way how to handle the methods to determine which Plugin is eligible to become a child of another plugin.
Currently, when we open the CMS in structure mode, the Placeholder and its attached Plugins know which plugins may be added as children to an existing plugin. This is determined by each plugin through its attributes
parent_plugins
andchild_plugins
. These attributes may be eitherNone
or a list of strings. In the former case, all plugins are allowed as parent/children,whereas in the latter case, only the named plugins are eligible as parents/children.
This static assignment has some drawbacks
In an ecosystem of plugins from different vendors, beforehand we don't know, who may want to become the child of a plugin from another vendor. This could cause one vendor having to add his plugin to the list of allowed children from another vendor.
Computing the eligible parent-children relationships is time consuming. Therefore django-CMS caches this information internally, which removes the possibility to determine dynamically, for instance by evaluating the current context, which children plugins can be added to an existing plugin.
In structure mode, when rendering a deep tree of plugins, each plugin comes with its own list of eligible children plugins. This can add many kilobytes of additional data to the payload, when transferring a CMS page in structure mode.
This rigid system of parent-children relationships, does for instance not allow to add kinds of intermediate plugins, such as wrappers or logical segments.
Therefore I want to propose a different method to determine which plugins are allowed as children of another plugin. Instead of computing this list statically before the CMS page is rendered, we should add a REST endpoint, which computes this relationship dynamically and based on the current context.
This list then is transferred from the server to the client and is used to render a list of possible
children plugins. The computation of this list should work as follows:
allowed_as_child_of()
for each of the plugins of the pool,passing its own instance and the current context.
This computation can now be much more time consuming. This is because we only have to do it
whenever the user clicks on the
+
symbol inside the plugin editor, rather than havingto do it for all plugins inside the pool. Even if such a computation requires 200 milliseconds,
since this it is part of the user's interaction, this would disturb.
Possible new Features
Plugin systems, which map the Bootstrap grid, usually encounter the following problem:
A row may be part of a container, and columns may be part of that row. An accordion, carousel,
panel and similar elements can either be children of the container, the row or the column.
Depending below which of these elements an accordion panel is placed, its own children then
shall either be either rows, columns or plain content. This means that whenever
allowed_as_child_of()
of an element is invoked, that method could check its potentialparent element, and if that does not contribute to the Bootstrap's grid structure (such as said
accordion, carousel, panel, etc.) it can go up a further level in the tree.
This feature would also make it possible to allow plugins depending on the siblings context.
Backwards Compatibility
Since we don't need the complicated caching functionality anymore, I even believe that it
reduces the amount of code. By adding an overridable method
allowed_as_child_of()
to thebase class
CMSPluginBase
, this feature could even be implemented in a backward compatiblemanner. This method then just would have to examine the plugin's attribute
parent_plugins
and the attribute of its ancestor
child_plugins
to determine whether it is allowed ofbeing added or not.
Implementation
In case the django-CMS community agrees on this proposal, I will implement this feature so
that it is available in a future major release. With this in mind, I'd like to open a discussion
about it.
Beta Was this translation helpful? Give feedback.
All reactions