如何默认为内容发布的当前日期和时间?

时间:2022-04-10 21:53:44

In this link, http://plone.org/documentation/how-to/set-default-datetimefield-current-date-time it describes how to do this with new Schema attributes. I could update all umpteen content types in our system use this method, but I would prefer something a bit less work intensive, since if I have to change umpteen content types it will be all too easy to make a mistake.

在此链接中,http://plone.org/documentation/how-to/set-default-datetimefield-current-date-time描述了如何使用新的Schema属性执行此操作。我可以在我们的系统中更新所有无用的内容类型使用这种方法,但我更喜欢一些工作密集程度较低的东西,因为如果我必须改变无数的内容类型,那么就很容易犯错误。

3 个解决方案

#1


maybe a js soln? have an onload event that looks for datetime widgets by id (or one of those common attributes) and then reset the time based on the browser time. You can filter new vs edit based on whether or not a non-prefilled required attribute has been filled yet (i.e. Title)

也许是一个js soln?有一个onload事件,它按id(或其中一个常用属性)查找datetime小部件,然后根据浏览器时间重置时间。您可以根据是否已填充非预填充的必需属性(即标题)来过滤新的vs编辑

#2


You could use archetypes.schemaextender to modify those types with an adapter:

您可以使用archetypes.schemaextender使用适配器修改这些类型:

in your configure.zcml

在您的configure.zcml中

<adapter
    factory=".adapters.DefaultDateModifier"
    name="my-package-defaultdate"
    />

in the adapters.py

在adapters.py中

class DefaultDateModifier(object):
    """DefaultDateModifier adapter
    """
    # XXX optionally adapt your content items iface here
    adapts(ATCTMixin)
    implements(ISchemaModifier)

    def fiddle(self, schema):
        # TODO switch out the default_method here...
        pass

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

#3


I could just make 'published' be the default work flow state. That should address the issue.

我可以让'已发布'成为默认的工作流状态。那应该解决这个问题。

#1


maybe a js soln? have an onload event that looks for datetime widgets by id (or one of those common attributes) and then reset the time based on the browser time. You can filter new vs edit based on whether or not a non-prefilled required attribute has been filled yet (i.e. Title)

也许是一个js soln?有一个onload事件,它按id(或其中一个常用属性)查找datetime小部件,然后根据浏览器时间重置时间。您可以根据是否已填充非预填充的必需属性(即标题)来过滤新的vs编辑

#2


You could use archetypes.schemaextender to modify those types with an adapter:

您可以使用archetypes.schemaextender使用适配器修改这些类型:

in your configure.zcml

在您的configure.zcml中

<adapter
    factory=".adapters.DefaultDateModifier"
    name="my-package-defaultdate"
    />

in the adapters.py

在adapters.py中

class DefaultDateModifier(object):
    """DefaultDateModifier adapter
    """
    # XXX optionally adapt your content items iface here
    adapts(ATCTMixin)
    implements(ISchemaModifier)

    def fiddle(self, schema):
        # TODO switch out the default_method here...
        pass

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

#3


I could just make 'published' be the default work flow state. That should address the issue.

我可以让'已发布'成为默认的工作流状态。那应该解决这个问题。