Search code examples
django-cms

How to create a placeholder for a specific plugin in django-cms 3.0.0


How do i create a placeholder that can only be filled with a specific plugin? I'd like to create a template in django-cms 3.0.0.beta2, with a placeholder only for the pictures plugin. I couldn't find any option in the docs.

http://django-cms.readthedocs.org/en/develop/advanced/templatetags.html


Solution

  • Using the placeholder "slot name" (first argument to {% placeholder %} or first argument to PlaceholderField, depending on which you use) and CMS_PLACEHOLDER_CONF you can limit a placeholder to only allow a single type of plugin.

    For example: if you have a placeholder in your template which looks like {% placeholder 'main_image' %}, the corresponding CMS_PLACEHOLDER_CONF value in settings.py would be:

    CMS_PLACEHOLDER_CONF = {
        'main_image': {
            'plugins': ['PicturePlugin']
        }
    }