Chris Parjaszewski
Chris Parjaszewski

Reputation: 11

Django CMS nested plugin inside parent plugin

I have rather a general question or a feature request, not sure. Looks like a very common use case, but I couldn't find any useful information though.

I'm trying to prepare around 10-15 custom "high-order" plugins that will consist of simple:

I'd like these "high-order" to be available for the user in the plugin dropdown and when he selects one - it will add that plugin with nested plugins automatically.

Links to images below:

So say I have a list of the following "high-order" plugins:
image-1

Another example - let's assume I'm creating a plugin that looks like this bar:
image-2

I imagine it will automatically add multiple buttons, text and header fields as nested/child plugins into my parent plugin.

Is that easily possible within Django CMS? I was googling for nested plugins, but couldn't find any useful information about it.

Upvotes: 1

Views: 746

Answers (1)

markwalker_
markwalker_

Reputation: 12869

You can configure default plugins for a placeholder which would take care of this. There's an example from the docs that illustrates this with the default text plugin as an example, created with two link plugins;

CMS_PLACEHOLDER_CONF = {
    'content': {
        'name': _('Content'),
        'plugins': ['TextPlugin', 'LinkPlugin'],
        'default_plugins': [
            {
                'plugin_type': 'TextPlugin',
                'values': {
                    'body': '<p>Great websites : %(_tag_child_1)s and %(_tag_child_2)s</p>'
                },
                'children': [
                    {
                        'plugin_type': 'LinkPlugin',
                        'values': {
                            'name': 'django',
                            'url': 'https://www.djangoproject.com/'
                        },
                    },
                    {
                        'plugin_type': 'LinkPlugin',
                        'values': {
                            'name': 'django-cms',
                            'url': 'https://www.django-cms.org'
                        },
                        # If using LinkPlugin from djangocms-link which
                        # accepts children, you could add some grandchildren :
                        # 'children' : [
                        #     ...
                        # ]
                    },
                ]
            },
        ]
    }
}

Upvotes: 2

Related Questions