[opencms-dev] 回复: Why my document doesn't contain released date?

Fantasy toberich at qq.com
Mon Sep 3 15:04:07 CEST 2012


Hi, Wolfgang,

Thanks for your explanation.

What i need is when clicking Save button, the Date's value would be filled to datereleased. The Date has a default value as ${currenttime}, and I did fill the date's value when editing, but nothing happened after saved. What's going on?

Fantasy





------------------ 原始邮件 ------------------
发件人: "Wolfgang Illmeyer"<wolfgang.illmeyer at gmx.net>;
发送时间: 2012年9月2日(星期天) 晚上7:35
收件人: "The OpenCms mailing list"<opencms-dev at opencms.org>; 

主题: Re: [opencms-dev] Why my document doesn't contain released date?



 
Hi,
 
 
 
What you specified is supposed to take the contents of the "Date" field of the structured content and write it to a "datereleased" property on certain occasions (e.g. when you press "save" in the structured content editor). If you don't put anything in the "Date" field, nothing will happen at all.
 
 
 
If you want a "release date" (whatever that could be), I'd recommend to use OpenCms API to to extract it from the CmsResource somehow (instead of explicitly storing it, if possible), or maybe there is some <cms:...> tag that can do that, too.
 
 
 
If you think of "release date" as the date of the last publish of the file,  you can CmsObject.readAllAvailableVersions(),  execute getPublishTag() on the first I_CmsHistoryResource and use the result to CmsObject.readHistoryProject(), which has a getPublishingDate().
 
 
 
If you think of "release date" as the date of the first publish of the file... Maybe you should fill it automatically by listening to I_CmsListener.EVENT_BEFORE_PUBLISH_PROJECT. You'll need to implement and register an I_CmsModuleAction class for you module to achieve that.
 
 
 
Regards,
 
Wolfgang
 
 
 
 
 
Am Sonntag, 2. September 2012, 11:38:30 schrieb Fantasy:

 
Hi, all,

I defined a document schema file, and add the following mapping, but when i check in the file list, non of the documents contain the realeased date. Why?

the definitions:
<xsd:complexType name="OpenCmsVideoDocument">
    <xsd:sequence>
        <!--  some other attributes -->
        <xsd:element name="Date" type="OpenCmsDateTime" minOccurs="1" maxOccurs="1"/>
        <xsd:element name="URL" type="OpenCmsString" minOccurs="1" maxOccurs="1"/>
        <!--  some other attributes -->
    </xsd:sequence>
    <xsd:attribute name="language" type="OpenCmsLocale" use="required"/>
</xsd:complexType>

the mappings:
<mappings>
    <!-- some other mapping -->
    <mapping element="Keywords" mapto="property:Keywords"/>
    <mapping element="Date" mapto="property:datereleased"/>
</mappings>


Thanks.

Fantasy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20120903/68033217/attachment.htm>


More information about the opencms-dev mailing list