sharepoint主题样式定制

来源:互联网 发布:百度seo教程蒋晖 编辑:程序博客网 时间:2024/04/19 18:46

主题样式

简介:

    SharePoint2013关于主题样式的问题,相信大家都比较头疼,其实SharePoint有很好的解决方法。这里介绍一个自定义主题样式的方法。通过一个feature选择适合自己的样式,其它网站集只要激活该feature就能应用该主题。

实现:

   添加模板页:

1、  添加一个module元素

2、  设置Elements

<span style="font-size:18px;"><?xml version="1.0"encoding="utf-8"?><Elementsxmlns="http://schemas.microsoft.com/sharepoint/"> <Module Name="MasterPage"Url="_catalogs/masterpage">   <File Url="MyMasterPage.master"Type="GhostableInLibrary"         Path="MasterPage\MyMasterPage.master"IgnoreIfAlreadyExists="true">     <Property Name="UIVersion" Value="15" />     <Property Name="ContentTypeId" Value="0x010105"/>   </File> </Module></Elements></span>


添加主题样式

1、  添加一个module元素

2、  在当前目录下上传你的样式文件 这里叫(MyTheme.spcolor

3、  写Elements元素

<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?><Elements xmlns="http://schemas.microsoft.com/sharepoint/">  <Module Name="Theme" Url="_catalogs/theme/15">    <File Path="Theme\MyTheme.spcolor" Url="MyTheme.spcolor"           Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" />  </Module></Elements></span>

添加字体设置

在上一个module中添加字体文件(MyFontScheme.spfont

Element中添加一行元素

<span style="font-size:18px;"><File Path=”Theme\MyFontScheme.spfont” Url=”MyFontScheme.spfont”Type=”GhostableInLibrary” IgnoreIfAlreadyExists=”TRUE” /></span>

添加功能

添加feature,再为其添加监听事件。

将上面做的module添加到feature中去,在feature正激活事件中写。

 

<span style="font-size:18px;">publicoverridevoid FeatureActivated(SPFeatureReceiverProperties properties)        {   conststring ThemeUrl = "_catalogs/theme/15/bingoPalette012.spcolor";            conststring FontSchemeUrl = "_catalogs/theme/15/bingofontscheme002.spfont";            var site =properties.Feature.Parent asSPSite;            if (site != null)            {                var serverRelativeUrl =site.RootWeb.ServerRelativeUrl;               site.RootWeb.ApplyTheme(serverRelativeUrl + ThemeUrl, serverRelativeUrl+ FontSchemeUrl, null, true);                                   }}</span>

这里的feature是向site级别部署的。

注意

   当前站点的http://主机ip/_catalogs/theme/15/bingoPalette012.spcolor

要能找文件,如果找不到,将文件传上去。

总结

    对于陌生的东西比较害怕,其实都是纸老虎。多看些,多了解些。

0 0
原创粉丝点击