将网页添加到空白共享点站点定义 [英] Adding web page to blank sharepoint site definition

查看:52
本文介绍了将网页添加到空白共享点站点定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 Sharepoint (2007) 完全陌生,所以请耐心等待.我想在创建新站点时自动创建 aspx 页面.这些页面将通过由母版页定义的选项卡链接到.我没有自定义站点定义,并计划将功能装订应用于开箱即用的空白站点定义.

I am totally new to Sharepoint (2007) so please bear with me. I would like to automatically create aspx pages when a new site is created. These pages will be linked to through tabs which will be defined by a master page. I do not have a custom site definition and was planning to apply feature stapling to the out of the box blank site definition.

通过我的研究,我认为您可以创建一个 Web 部件页面并将其转化为功能.然后我可以将其装订到空白站点定义中.问题是我没有找到有关如何执行此操作的任何信息.所以我的两个问题是:

Through my research, I think you can create a web part page and turn this into a feature. I can then staple this to the blank site definition. The problem is I haven't found any information on how to do this. So the two questions I have are:

  1. 如何创建仅是 aspx 页面的功能?
  2. 如何将此功能装订到空白站点定义中?

我在这里发现有人在问同样的问题:如何将 Web 部件页面添加到站点定义?我阅读了第一个回复,但它有点让我无法理解,我不知道它是否真的回答了我的问题.

I found one person asking the same question here: How to add a web part page to a site definition? I read the first response but it sort of goes over my head and I don't know if it really answers my question.

非常感谢!

推荐答案

第一个问题的答案取决于您指的是应用程序页面还是内容页面.它们各有优点:应用程序页面的优点在于它们可以运行自定义的服务器端代码,而内容页则很好,因为(例如)它们可以由用户自定义,但默认情况下限制了可以使用的代码类型运行.

The answer to your first question depends on whether you mean application pages or content pages. They each have their advantages: application pages are good in that they can run custom server-side code, and content pages are nice because (for example) they can be customized by users, but by default are restricted in what kind of code can be run.

有关这两种类型在功能和限制方面的差异的很好的讨论,请查看 Windows SharePoint Services SDK 并查看名为应用程序_布局页面类型" 和 "内容页面类型."

For a pretty good discussion on the differences between the two types in capabilities and restrictions, check out the Windows SharePoint Services SDK and look at the topics called "Application _layouts page type" and "Content page type."

至于装订,这比向站点定义的 onet.xml 文件添加新功能要简单和灵活.这篇文章 似乎很好地概述了替代方案.不过,您可能希望复制空白站点定义,重命名,然后在您的工作中使用该定义.

As for stapling, it's pretty easy and more flexible than adding new features to a site definition's onet.xml file. This article seems a pretty good overview of the alternatives. You might want to make a copy of the blank site definition, rename it, and then use that one in your work, though.

内容页面的功能

为此您需要三种类型的东西:

You'll need three types of things for this:

  1. 一个 feature.xml 文件——只是引用元素清单的样板文件.
  2. 页面模板 -- 这可以是整个 aspx 页面本身,也可以是(例如)定义了 WebPartZones 但没有实际 Web 部件(尚未)的 Web 部件页面的外壳.
  3. 元素清单文件,它引用您的页面模板并定义应作为激活功能的一部分进行配置的任何 Web 部件.
  1. A feature.xml file -- just the boilerplate stuff that refers to the element manifest.
  2. A page template -- this could be the entire aspx page itself, or it could be (for example) a shell of a web part page with WebPartZones defined but no actual web parts (yet).
  3. The element manifest file which refers to your page templates and defines any web parts that should be provisioned as part of activation of your feature.

您的功能的文件夹结构如下所示:

Your feature's folder structure would look something like this:

12
+-- TEMPLATES
    +-- FEATURES
        +-- YourFeature
            +-- PageTemplates
            |   +-- Page.aspx (simple aspx page)
            |   +-- WebPartPage.aspx (still simple, but with WebPartZones)
            +-- feature.xml
            +-- elements.xml

Feature.xml:

<Feature 
  Id="CFF117BC-9685-4a7b-88D0-523D9DAD21F0"
  Title="Custom Pages Feature"
  Scope="Web"
  xmlns="http://schemas.microsoft.com/sharepoint/">
  <ElementManifests>
    <ElementManifest Location="elements.xml"/>
  </ElementManifests>
</Feature>

Elements.xml

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Path="PageTemplates" Url="Pages" >
    <File Url="Page.aspx" Type="Ghostable" />
    <File Url="WebPartPage.aspx" Name="WebPartPage.aspx" Type="Ghostable" >
      <AllUsersWebPart WebPartZoneID="Left" WebPartOrder="0">
        <![CDATA[         
            <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"
                     xmlns:cewp="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
                <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
                <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
                <Title>Some content that you want to provision with the feature</Title>
                <FrameType>TitleBarOnly</FrameType>
                <cewp:Content>
                  Hello world.
                </cewp:Content>
            </WebPart>
        ]]>
      </AllUsersWebPart>
    </File>
  </Module>
</Elements>

Page.aspx

<%@ Page MasterPageFile="~masterurl/default.master" 
    meta:progid="SharePoint.WebPartPage.Document"  %>
<asp:Content runat="server" ContentPlaceHolderID="PlaceHolderMain">
  Hello World
</asp:Content>

WebPartPage.aspx

<%@ Page Language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document"   %>

<%@ Register Tagprefix="WebPartPages" 
             Namespace="Microsoft.SharePoint.WebPartPages" 
             Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<asp:Content ID="main" runat="server" ContentPlaceHolderID="PlaceHolderMain" >

<table width="100%">
  <tr>
    <td valign="top" style="width:50%">
        <WebPartPages:WebPartZone ID="Left" runat="server" 
                      FrameType="TitleBarOnly" Title="Left Web Part Zone" />
    </td>
    <td valign="top" style="width:50%">
        <WebPartPages:WebPartZone ID="Right" runat="server" 
                     FrameType="TitleBarOnly" Title="Right Web Part Zone" />        
    </td>
  </tr>
</table>

</asp:Content>

如果您以这种方式配置您的功能,您应该能够在该结构中部署站点内容页面.

If you configure your feature in that way, you should be able to deploy site content pages within that structure.

另外,我强烈推荐 Ted Pattison 的 Inside Windows SharePoint Services 书.它详细介绍了这个主题,包括站点内容页面的重要安全方面.物有所值.

Also, I highly recommend Ted Pattison's Inside Windows SharePoint Services book. It covers this topic in much detail, including the important security aspects of site content pages. It's easily worth the purchase price.

这篇关于将网页添加到空白共享点站点定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆