我希望得到您在两点上的帮助:
首先,我创建一些默认页面的模板,例如: “Home.html、work-with-us.html”等
我的目标是简化网站负责人的工作。他们不必学习如何管理占位符内的插件。
因此,我创建了一些像这样的占位符,例如“workwithus.html”:
{% extends "base.html" %}
{% load cms_tags staticfiles sekizai_tags menu_tags %}
{% block content %}
<div class="container">
<div class="col-xs-12">
{% placeholder "image-full" %}
</div>
<div class="col-md-12">
{% placeholder "text-platform" %}
</div>
</div>
{% endblock content %}
我是这样管理插件的:
CMS_PLACEHOLDER_CONF = {
'image-full': {
'plugins': ['FilerImagePlugin'],
'name': gettext("Image full page"),
'default_plugins': [
{
'plugin_type': 'FilerImagePlugin',
'values': {
},
},
],
'limits': {
'global': 1,
'FilerImagePlugin': 1,
},
},
等等
问题是,我不能在同一个模板中多次使用相同的占位符。如果当我制作占位符“img-full-width”时我可以多次调用它,那就太好了。 你对此有什么想法吗?一种比创建“img-full-2”、“img-full-3”等更合适的方法。
第二个问题: 是否可以添加多个 default_plugins ?实在是让我很烦恼……
提前非常感谢你们!
最佳答案
您可以拥有任意数量的插件 default_plugins
You can specify the list of default plugins which will be automagically added when the placeholder will be created (or rendered).
如果您对必须为每个占位符重新定义 CMS_PLACEHOLDER_CONF
感到烦恼,您始终可以在 CMS_PLACEHOLDER_CONF
block 之前定义一个通用配置:
img_fullwidth_conf = {
'plugins': ['FilerImagePlugin', 'TextPlugin'],
'name': gettext("Image full page"),
'default_plugins': [
{
'plugin_type': 'FilerImagePlugin',
'values': {
},
},
{
'plugin_type': 'TextPlugin',
'values': {
'body': '<p>Write here...</p>'
},
},
],
}
CMS_PLACEHOLDER_CONF = {
'img-full-1': img_fullwidth_conf,
'img-full-2': img_fullwidth_conf,
'img-full-3': img_fullwidth_conf,
}
关于Django CMS 管理模板页面中的占位符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29119430/