Django CMS 占位符:插件黑名单

Django CMS Placeholder: Plugin Blacklist

创建自定义插件后,网站上的每个 placeholder 都可以使用它。如果我希望它们仅在特定的 static_placeholder 上可用并排除在其余部分之外怎么办?

我知道 documentation 告诉我如何在每个占位符上手动包含每个插件,但不知道如何从中排除插件。目前可以吗?

我正在开发 Django CMS 3.1.2

目前只能将插件列入白名单,不能列入黑名单。这意味着现在,您必须在所有其他占位符上指定所有插件(自定义插件除外)的列表(请注意,您可以 select 模板中的所有占位符通过使用模板作为键),并定义包含自定义插件的静态占位符列表。

可能也值得在 django CMS Issue Tracker 上提出这个问题,以便在未来的版本中找到更好的解决方案。

ojii 回答的后续:

虽然目前正在批准合并(参见#5412),但yakky描述的方法如下:

To implement blacklist, add the plugin to be blacklisted in CMS_PLACEHOLDER_CONF[None]['excluded_plugins'] list

#4979

谢谢@yakky :)

编辑:更多信息来自Issue #5412

Sometimes a global configuration would make things much nicer / simpler

@ojii suggested a for level structure like (in increasing order of precedence)

CMS_PLACEHOLDER_CONF[None] (global)

CMS_PLACEHOLDER_CONF['template'] (if template is given)

CMS_PLACEHOLDER_CONF['placeholder']

CMS_PLACEHOLDER_CONF['template placeholder'] (if template is given)

编辑 2 在 Django CMS 3.4.0 上尝试了这些新配置并且它运行完美

CMS_PLACEHOLDER_CONF = {
    'About': {
        'excluded_plugins': ['CMSArticlePlugin', 'FormPlugin'],
    },
    'Contact': {
        'excluded_plugins': ['CMSArticlePlugin'],
    },
    'Editions': {
        'excluded_plugins': ['CMSArticlePlugin', 'FormPlugin'],
    },
    'Involved': {
        'excluded_plugins': ['CMSArticlePlugin', 'FormPlugin'],
    },
    'Gallery': {
        'excluded_plugins': ['CMSArticlePlugin', 'FormPlugin'],
    },
    'News': {
        'excluded_plugins': ['FormPlugin'],
    },
}

干得好,Django CMS 团队!