代码之家  ›  专栏  ›  技术社区  ›  robasta

我有一个sharepoint解决方案,下一步怎么办

  •  0
  • robasta  · 技术社区  · 15 年前

    如何将母版页添加到Sharepoint?我该怎么办?

    3 回复  |  直到 15 年前
        1
  •  1
  •   Famous Nerd    15 年前

    WSPBuilder

    母版页作为一个“模块”部署到sharepoint中,您将把它放入功能中的elements.xml文件中。

    把一个解决方案想象成一个扩展名不同的.cab文件。其中有一个名为feature.xml的文件,它定义了部署包时包的标题。可以激活和停用功能以将内容部署和取消部署到服务器场的某些部分。

    下面是一个作为模块部署的css文件的示例。。。母版页与此类似,但是它们将部署到母版页库而不是样式库中。此模块将自定义css文件部署到网站集的“样式库”中。部署之后,我使用“Feature Receiver”(事件处理程序)获取对SPSite对象的引用,并修改其备用样式表,以便进行重写。

    <?xml version="1.0" encoding="utf-8" ?>
    <Feature xmlns="http://schemas.microsoft.com/sharepoint/" 
             Id="63BB13A0-1F9C-4c3b-BE60-10E59CEE0113"
             Title="Custom CSS Feature"
             Description="Deploying a custom CSS using a feature"
             Version="1.0.0.0"
             Hidden="FALSE"
             Scope="Site"
             ReceiverAssembly="CustomCSSFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=24f1377a8414d2ed"
             ReceiverClass="CustomCSSFeature.FeatureReceivers.CustomCSSFeatureReceiver"
             >
      <ElementManifests>
        <ElementManifest Location="elements.xml"/>
      </ElementManifests>
    </Feature>
    

    elements.xml—您可以修改它以反映母版页应该部署在哪里,我认为这是Url属性。Path=“Styles”是指样式表所在的功能本身内的相对路径(例如,在您的visual studio中,我在名为CustomCSSFeature的文件夹下有一个名为Styles的子文件夹,而该文件夹正是样式表所在的位置)

        <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
      <Module Name="OSGStyles" Url="Style Library" Path="Styles" RootWebOnly="TRUE">
        <File Url="custom-css.css" Type="GhostableInLibrary" />
      </Module>
    </Elements>
    

    然后,在我的featurereceiver类中,我激活/停用了将样式表“应用”到发布web的处理程序。在您的情况下,您也可以在FeatureReceiver中更改网站的默认母版页。

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;
    
            using (SPWeb web = site.OpenWeb())
            {
                PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
                publishingWeb.AlternateCssUrl.SetValue(web.ServerRelativeUrl + 
                    "/Style Library/custom-css.css", true);
                publishingWeb.Update();
                web.Update();
            }
        }
    
        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;
    
            using (SPWeb web = site.OpenWeb())
            {
                PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
                publishingWeb.AlternateCssUrl.SetValue("", true);
                publishingWeb.Update();
                web.Update();
            }
        }
    
        2
  •  0
  •   Janis Veinbergs    15 年前

    将它们复制到SharePoint根目录(对于SP 2007,默认位置为 C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\ ,对于SP 2010而不是“12”,您有“SharePointRoot”)

    \TEMPLATE\LAYOUTS 文件夹,然后您可以从aspx页面引用母版页,如“/\u layouts/mymasterpage.master”。

    用户控件进入 \TEMPLATE\CONTROLTEMPLATES

    Get to know the directory structure in the 12 Hive

    Exploring the 12 Hive : TEMPLATE Directory

    另一种方法是把你的母版页放到母版页列表中。使用此链接访问母版页列表并上载母版页:http://\u catalogs/masterpage

        3
  •  -1
  •   Community Mohan Dere    8 年前

    可以使用添加母版页 SharePoint Designer 2007

    一般来说,我建议你看看这个问题的答案: Learning Sharepoint