我正在嘗試使Keystone進入CMS。所以,我需要文章,類別,ImagePage,AttachmentPage等模型。我提到的每個模型都有一些常用字段,如:標題,內容,元:{title,description,keywords}等等。如何重新排序Keystone的管理界面中的字段
在梯形校正模型構造是這樣的:
Article.add(fieldsCollectionObject)
,所以我定義在外部文件中的公共字段:
var T = require('keystone').Field.Types;
module.exports = {
title: { type: T.Text, required: true },
content: { type: T.Html, wysiwyg: true, height: 400 },
meta: {
title: { type: T.Text },
desc: { type: T.Textarea, height: 50 },
keywords: { type: T.Text },
},
publishedDate: { type: T.Date, index: true, dependsOn: { state: 'published' } },
state: { type: T.Select, options: 'draft, published, archived', default: 'draft', index: true },
};
,並在模型文件中有require'd它我做的:
const _ = require('lodash');
const pageDef = require('./common/Page.js');
const keystone = require('keystone');
const T = keystone.Field.Types;
<...>
Article.add(_.defaultsDeep({
brief: { type: T.Html, wysiwyg: true, height: 150 },
category: { type: T.Relationship, ref: 'Category', many: false, collapse: true },
tags: { type: T.Relationship, ref: 'Tag', many: true },
}, defs.authored, pageDef));
現在,問題是在管理界面的字段順序 - 不出所料brief
,category
和tags
從pageDef
開始。有什麼辦法可以施加我想要的訂單嗎?像title
,brief
,content
,<the rest>
?
就是這樣!我貼上了自己尋找像「排序:x」或類似的字段定義屬性,但你的解決方案更簡單但聰明。我將它擴展爲將實體頁面的分割部分與標題區分開來,當然還有功勞。:)感謝您的幫助! – Forseti