【发布时间】:2018-01-02 23:35:32
【问题描述】:
我想让“已发布”选项默认设置为“假”,而不是“真”。
我试图在撇号自定义页面中使用它:
但它不起作用! 你能帮忙吗?
谢谢
编辑:完整的 index.js 也许我的默认选项在其他地方被覆盖了?
var _ = require('lodash');
module.exports = {
extend: 'apostrophe-doc-type-manager',
beforeConstruct: function(self, options) {
options.name = options.name || self.__meta.name.replace(/\-pages$/, '-page');
if (options.permissionsFields === undefined) {
// By default, pages have nuanced permissions
options.permissionsFields = true;
}
options.addFields = [
{
type: 'boolean',
name: 'published',
label: 'Published',
def:false
},
{
type: 'slug',
name: 'slug',
label: 'Slug',
required: true,
// with this flag, a leading / is enforced, and slashes
// elsewhere are allowed etc.
page: true
},
{
type: 'select',
name: 'type',
label: 'Type',
required: true,
choices: _.map(options.apos.pages.typeChoices, function(type) {
return {
value: type.name,
label: type.label
};
})
},
{
type: 'boolean',
name: 'orphan',
label: 'Hide in Navigation'
}
].concat(options.addFields || []);
options.arrangeFields = [
{
name: 'basics',
label: 'Basics',
fields: [ 'meta-description', 'title', 'slug', 'type','alaune', 'color', 'published', 'tags', 'orphan' ]
}
].concat(options.arrangeFields || []);
},
construct: function(self, options) {
require('./lib/dispatch.js')(self, options);
require('./lib/api.js')(self, options);
}
};
哈哈,我喜欢这个网站,但是如果没有更多的 cmets,我就无法发布我的代码!好吧,我的问题很容易解释。
所以 .. 我要感谢 apostrophe-cms 团队所做的出色工作^^ 以及 Tom 的耐心支持!
【问题讨论】:
-
应该可以。你把它放在
beforeConstruct吗?请发布更完整的代码。谢谢! -
你好汤姆,谢谢你的回复可以在另一个文件上覆盖这个默认选项吗?
标签: apostrophe-cms