设为首页 收藏本站
查看: 1329|回复: 0

[经验分享] sharepoint 2010 自定义页面布局

[复制链接]

尚未签到

发表于 2015-9-24 09:55:53 | 显示全部楼层 |阅读模式
  在sharepoint开发中经常遇到 自定义网站栏、内容类型,页面布局和模板页也会遇到,遇到机会就相对比较小。
  首先新建一个空的sharepoint项目:
  1)创建网站兰:
DSC0000.png
  修改SiteColumns\Elements.xml文件如下:


DSC0001.gif DSC0002.gif


<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field ID="{76C140E1-D827-433B-AD38-257F9594B846}"
Name="BenefitProvider"
DisplayName="Provider Name"
Group="Human Resources"
Type="Text"
Required="FALSE"/>
<Field ID="{A1758D70-B479-469C-90BB-C3038ED42B15}"
Name="BenefitProviderLogo"
DisplayName="Provder Logo"
Group="Human Resources"
Type="Image"
Required="FALSE"/>
<Field ID="{5F516D92-969C-4661-81B9-C9210E2A2FDC}"
Name="BenefitType"
DisplayName="Benefit Category"
Group="Human Resources"
Type="Choice"
Required="FALSE">
<CHOICES>
<CHOICE>Medical</CHOICE>
<CHOICE>Dental</CHOICE>
<CHOICE>Vision</CHOICE>
<CHOICE>Insurance</CHOICE>
</CHOICES>
</Field>
<Field ID="{521D5F12-16BC-4E82-997C-F28933ABE59E}"
Name="BenefitDescription"
DisplayName="Benefit Description"
Group="Human Resources"
Type="HTML" RichText="TRUE" RichTextMode="FullHtml"
Required="FALSE"/>
</Elements>
View Code   2)创建内容内型
DSC0003.png
  修改ContentTypes\Elements.xml文件如下:





<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Parent ContentType: 文章页面 (0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D) -->
<ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D0086e87a8467684813ad2d89881b6da33d"
Name="Benefits Information Page"
Group="Human Resources"
Description="Benefits Information page layout content type"
Inherits="TRUE"
Version="0">
<FieldRefs>
<FieldRef ID="{76C140E1-D827-433B-AD38-257F9594B846}" Name="BenefitProvider"/>
<FieldRef ID="{A1758D70-B479-469C-90BB-C3038ED42B15}" Name="BenefitProviderLogo"/>
<FieldRef ID="{5F516D92-969C-4661-81B9-C9210E2A2FDC}" Name="BenefitType"/>
<FieldRef ID="{521D5F12-16BC-4E82-997C-F28933ABE59E}" Name="BenefitDescription"/>
</FieldRefs>
</ContentType>
</Elements>
View Code   注意这里的<FieldRef ID="{76C140E1-D827-433B-AD38-257F9594B846}" Name="BenefitProvider"/>是刚才创建网站栏的ID。
  3)创建自定义 页面布局
  我这里推荐大家在sharepoint Designer把页面布局的内容创建好,然后再用feature在部署。
  在sharepoint Designe中:
DSC0004.png
  在用sharepoint designer导出改文件
  在VS中
DSC0005.png
  把那个文本文件从命名为BenefitsInformation.aspx,把先前sharepoint designer导出文件的内容拷贝到这个文件上来。





<%@ Page language="C#"   Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:webpartpageexpansion="full" meta:progid="SharePoint.WebPartPage.Document" %>
<%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server">
<SharePointWebControls:FieldValue id="PageTitle" FieldName="Title" runat="server"/>
</asp:Content>
<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">
<SharePointWebControls:TextField FieldName="76c140e1-d827-433b-ad38-257f9594b846" runat="server"></SharePointWebControls:TextField>
<PublishingWebControls:RichImageField FieldName="a1758d70-b479-469c-90bb-c3038ed42b15" runat="server"></PublishingWebControls:RichImageField>
<SharePointWebControls:DropDownChoiceField FieldName="5f516d92-969c-4661-81b9-c9210e2a2fdc" runat="server"></SharePointWebControls:DropDownChoiceField>
<PublishingWebControls:RichHtmlField FieldName="521d5f12-16bc-4e82-997c-f28933abe59e" runat="server"></PublishingWebControls:RichHtmlField>
</asp:Content>
View Code   修改BenefitsLayout\Elements.xml 文件:





<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="BenefitsLayout"  Url="_catalogs/masterpage" RootWebOnly="TRUE">
<File Path="BenefitsLayout\BenefitsInformation.aspx" Url="BenefitsInformation.aspx" Type="GhostableInLibrary">
<Property Name="Title" Value="Benefits Information Page" />
<Property Name="MasterPageDescription" Value="Use benefits page to publish content related to benefits information" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
<Property Name="PublishingAssociatedContentType" Value=";#Benefits Information Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D0086e87a8467684813ad2d89881b6da33d;#" />
</File>
</Module>
</Elements>
View Code   注意这里的   <Property Name="PublishingAssociatedContentType" Value=";#Benefits Information Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D0086e87a8467684813ad2d89881b6da33d;#" />中间这一长串就是我们先前定义的内容类型的ID。
  最后发布,发布结果如下:
  网站栏:
DSC0006.png
  内容类型:
DSC0007.png
DSC0008.png
  自定义页面布局:
DSC0009.png
  用我们自己的页面布局来创建一个页面
DSC00010.png
DSC00011.png bianjia DSC00012.png
  编辑信息如下:
DSC00013.png
  最后签入:
DSC00014.png
DSC00015.png

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-118063-1-1.html 上篇帖子: SharePoint 2013 使用查阅项实现联动下拉框 下篇帖子: SharePoint下在Feature中动态Register/Remove HttpModule
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表