0

我使用 archetypes.schemaextender 扩展了一个基本的 Plone 内容类型。我需要重新排序编辑页面上的字段。当我这样做时,重新排序的字段会出现在编辑界面上一个名为“内容”的新选项卡中。如何让字段显示在编辑界面的“默认”选项卡中?

这是我的extender.py 中的代码片段:

class extenddocument(object):
    adapts(IATDocument)
    implements(IOrderableSchemaExtender, IBrowserLayerAwareExtender)

    layer = IextenddocumentLayer

    fields = [
        _ExtensionStringField(
            name='longTitle',
            widget=StringWidget(
                label=u'Long Title',
                description=u'Optional descriptive title to replace default title as the page heading',
                size='50',
            ),
            required=False,
            searchable=True,
        ),
    ]

    def __init__(self, context):
        self.context = context

    def getOrder(self, schematas):
            """ Manipulate the order in which fields appear.
                @param schematas: Dictonary of schemata name -> field lists
                @return: Dictionary of reordered field lists per schemata.
            """
            schematas["Content"] = ['title', 'longTitle', 'description', 'text']
            return schematas

    def getFields(self):
        return self.fields

附件是编辑选项卡视图: 在此处输入图像描述

4

2 回答 2

3

在 getOrder 方法中,将字段列表分配给 schematas['default'] 而不是 schematas['Content']。

于 2014-03-24T23:42:37.600 回答
1

或者,由于您实际上不需要额外的字段集,因为无论如何添加的字段都将附加到默认字段集,您也可以重新排序您的字段 - 而不是整个字段集 - 如下所述:

http://developer.plone.org/content/archetypes/fields.html#reordering-fields

这是 Inqbus 的一个很好的文档,它为您提供了重新排序字段和字段集的可能性的概述,它是德语的,但代码部分是不言自明的:

http://inqbus-hosting.de/support/dokumentation/docs/plone-archetypes-schemata-und-fields

于 2014-03-25T09:09:45.150 回答