拆分SharePoint 2013 中CreatedModifiedInfo 的时间

时间:2023-03-09 18:31:05
拆分SharePoint 2013 中CreatedModifiedInfo 的时间

最近在自定义DisForm.aspx页面时 发现 创建时间信息无法进行拆分,人事MM只想要修改时间,去掉创建人,创建时间和修改人。

于是我的重新研究下在SPD里面如何去拆分这个时间。

在详情页面上找到的时间信息是如下控件。(默认的DisForm页面没有,这里我是新建了一个列表显示页面)

<SharePoint:CreatedModifiedInfo Visible="false" ControlMode="Display" runat="server"/>

其实就这个东东。但是在转换成html的时候会变成个table,所以我们要分析下里面有什么东西。

问了下其他人,列表的基本模板可以在C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES

的DefaultTemplates.ascx下找到具体对应的数据绑定,查找 CreatedModifiedInfo 大概在485行左右。

<SharePoint:RenderingTemplate id="CreatedModifiedInfo" runat="server">
<Template>
<table cellpadding="" cellspacing="">
<tr><td nowrap="nowrap" class="ms-descriptiontext" id="onetidinfoblock1">
<SharePoint:FormAuthorEditorFormattedString
UserOnlyFormatText="<%$Resources:wss,form_createdby_user%>"
AppOnlyFormatText="<%$Resources:wss,form_createdby_app%>"
UserAppFormatText="<%$Resources:wss,form_createdby_user_app%>"
IsAuthorField="true"
runat="server">
<SharePoint:FormField ControlMode="Display" FieldName="Created" DisableInputFieldLabel="true" runat="server"/>
<SharePoint:FormField ControlMode="Display" FieldName="Author" DisableInputFieldLabel="true" runat="server"/>
<SharePoint:CreationType runat="server"/>
<SharePoint:FormAppInfo ControlMode="Display" FieldName="AppAuthor" runat="server" />
</SharePoint:FormAuthorEditorFormattedString>
</td></tr>
<tr><td nowrap="nowrap" class="ms-descriptiontext" id="onetidinfoblock2">
<SharePoint:FormAuthorEditorFormattedString
UserOnlyFormatText="<%$Resources:wss,form_modifiedby_user%>"
AppOnlyFormatText="<%$Resources:wss,form_modifiedby_app%>"
UserAppFormatText="<%$Resources:wss,form_modifiedby_user_app%>"
IsAuthorField="false"
runat="server">
<SharePoint:FormField ControlMode="Display" FieldName="Modified" DisableInputFieldLabel="true" runat="server"/>
<SharePoint:FormField ControlMode="Display" FieldName="Editor" DisableInputFieldLabel="true" runat="server"/>
<SharePoint:FormAppInfo ControlMode="Display" FieldName="AppEditor" runat="server" />
</SharePoint:FormAuthorEditorFormattedString>
</td></tr>
</table>
</Template>
</SharePoint:RenderingTemplate>

这时,可以发现这个空间也是由许多数据绑定而成,例如

<SharePoint:FormField ControlMode="Display" FieldName="Created" DisableInputFieldLabel="true" runat="server"/>
<SharePoint:FormField ControlMode="Display" FieldName="Author" DisableInputFieldLabel="true" runat="server"/>

上面的代码是显示创建时间和创建人的。
我们回到原来的详细页面设计下。将

<SharePoint:FormField ControlMode="Display" FieldName="Modified" DisableInputFieldLabel="true" runat="server"/>

复制到需要显示的位置。

<tr>
<td width="190px" valign="top" class="ms-formlabel" style="display:none"> <H3 class="ms-standardheader">
<nobr>标题</nobr>
</H3>
</td>
<td width="400px" valign="top" class="ms-formbody" style="font-family:微软雅黑;font-weight:bolder;font-size:20px;text-align:center"> <xsl:value-of select="@Title"/>
</td>
</tr>
<tr>
<td colspan="" width="400px" valign="top" class="ms-formbody" style="font-family:微软雅黑;font-size:12px;text-align:center">
<SharePoint:FormField FieldName="Modified" runat="server" ControlMode="Display" DisableInputFieldLabel="true"/>
</td>
</tr>
<tr>
<td width="190px" valign="top" class="ms-formlabel" style="display:none"> <H3 class="ms-standardheader">
<nobr>Content</nobr>
</H3>
</td>
<td width="400px" valign="top" class="ms-formbody"> <xsl:value-of select="@Content" disable-output-escaping="yes"/> </td>
</tr>

具体显示的效果如下
拆分SharePoint 2013 中CreatedModifiedInfo 的时间

搞定~

收工!