Adding web page to blank sharepoint site definition

后端 未结 1 1821
一个人的身影
一个人的身影 2021-01-03 16:35

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 thro

1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-03 16:59

    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.

    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."

    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.

    Features with content pages

    You'll need three types of things for this:

    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:

    
      
        
      
    
    

    Elements.xml

    
      
        
        
          
            
                    Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c
                    Microsoft.SharePoint.WebPartPages.ContentEditorWebPart
                    Some content that you want to provision with the feature
                    TitleBarOnly
                    
                      Hello world.
                    
                
            ]]>
          
        
      
    
    

    Page.aspx

    <%@ Page MasterPageFile="~masterurl/default.master" 
        meta:progid="SharePoint.WebPartPage.Document"  %>
    
      Hello World
    
    

    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" %>
    
    
    
    

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

    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.

    0 讨论(0)
提交回复
热议问题