SharePoint 开发篇:浅谈Web Part和Page Layout 开发

Blog链接:https://blog.51cto.com/13969817

Design Manager 帮助很多开发者在SharePoint中创建自己的网站设计。通常我们根据站点设计进行定制母版页,因为它定义了贯穿站点所有页面的公共元素,你可以通过“站点设置”下的“Design Manager”并映射你的网络驱动器,使用任何HTML编辑器编辑母版页。

比如,主页上的搜索框可以帮助用户在网站上找到视频,在配置搜索设置之后,从gallery中插入一个搜索框,然后从Design Manager导航到搜索设置,并添加搜索中心URL,更新搜索片段并复制HTML。

示例代码:<div id="s4-bodyContainer">

而Page Layout是通过在母版页的公共元素中设置页面字段和Web部件区域的样式来定义一组页面的外观,前面映射的网络驱动器可用于使用任何HTML编辑器编辑页面布局。

开发Page layout的时候使用Design Manager来开发,这种开发方式是直接写html文件,对于页面需要用到的元素(e.g. webpart zone),可以通过snippet的方式添加,这种方式得好处是开发比较快。
比如我想为Media Web Part添加Web Part Zone snippet。

示例参考代码:

<!--CS: Start Web Part Zone Snippet-->
<!--SPM:<%@Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>-->
<div xmlns:ie="ie">
<!--MS:<WebPartPages:WebPartZone runat="server" AllowPersonalization="false" ID="x337a5a8d939248d49e9c39d87693bef0" FrameType="TitleBarOnly" Orientation="Vertical">-->
<!--MS:<ZoneTemplate>-->
<!--DC: Replace this comment with default web parts for new pages. -->
<!--ME:</ZoneTemplate>-->
<!--ME:</WebPartPages:WebPartZone>-->
</div>
<!--CE: End Web Part Zone Snippet-->

其他相关文章:Build your first SharePoint client-side web part (Hello World part 1)

猜你喜欢

转载自blog.51cto.com/13969817/2466523