当选择一种类型来显示它的小部件时,可以选择在几个widget.html模板之间进行选择,类似于在创建新页面时选择模板的方式。
这有可能以某种方式吗?
您可以在窗口小部件的架构中包含subType
字段:
addFields: [
{
name: 'subType',
type: 'select',
choices: [
{
value: 'red',
label: 'Red'
},
{
value: 'blue',
label: 'Blue'
}
]
}
]
然后,在你的widget.html
文件中,你可以写:
{% include data.widget.subType + '.html' %}
现在创建red.html
和blue.html
模板,你应该参加比赛。
希望这有用!