Suggestion: required_ancestor relation for plugins.

30 views
Skip to first unread message

Frédéric Roland

unread,
Jan 23, 2020, 12:55:32 PM1/23/20
to django CMS developers
Hello,
the parent/child based restriction for plugins is a bit too much restrictive for my use case.
I have a suggestion but I'm not sure how to implement it. I'd like some guidance on what to modify to achieve what I want.

The idea is to have a required_ancestor to some plugins.

For example in an ecommerce situation you would have a Product plugin that would make available a product model so all sub plugins that it would contain know to what product they are related.

[Page] =>
[Body placeholder] =>
[ProductPlugin Product=5] =>
[Bootstrap container] =>
[Row] =>
[Column] => [ProductImage]
[Column] => [ProductDescription]

That way, ProductPlugin set the context, we are building a page to display product 5.
Then when they are rendered ProductImage and ProductDescription would know what they would need to render (ie image and description for product 5).
ProductPlugin can allow any type of plugin.
ProductImage and ProductDescription need to have a productplugin somewhere but it's not required to have it as a direct parent.

So I'd like to have ProductImage and ProductDescription as available plugins if I clic [+] on the column plugin because there is a ProductPlugin ancestor
but if there is no ProductPlugin ancestor it would not be displayed.

Is somebody working on this kind of feature ?
Can I test/help to make it ?

Best regards,
Frédéric Roland

Jacob Rief

unread,
Jan 23, 2020, 5:02:07 PM1/23/20
to django CMS developers
Hello Frédéric,
this is something I always wanted to implement, because it makes the configuration of plugins unnecessarily difficult.

If you wonder, why I never implemented it: no spare time/lack of funding.

Best Regards,
Jacob

Frédéric Roland

unread,
Jan 23, 2020, 6:02:02 PM1/23/20
to django CMS developers
Hello Jacob,

I see that what I need require a lot of knowledge about how Django-CMS work at the javascript frontend level and I'm not there yet.

I found a quick work around.
My descendant child plugin has a list of ancestors that it can be included in and I get all the parents class name and compare.
If the required ancestor is found, I set a variable in the context to true and the template render the plugin.
If the required ancestor is *not* found, I set a variable in the context to false and the template render the plugin with an error message that list the required ancestors.

Frédéric
Reply all
Reply to author
Forward
0 new messages