sharepoint主题样式定制

主题样式

简介:

    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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值