简体   繁体   中英

SharePoint 2010 Solution

I'm creating a Site Definition for SharePoint 2010 using VS 2010. Have some questions:

  1. How do I limit the page layouts to the custom ones that I created?
  2. I created a custom Home Page layout. How do I by default create a page based on this page layout and set it as the welcome page for the site?

Your implementation approach (either declarative or programmatic) isn't indicated in your question so I am only assuming that you are building your custom site definition declaratively (with CAML). You will find that creating a custom site definition declaratively is pretty painful, especially when debugging. It usually involves making changes to the onet.xml file and just hoping things go right during deployment and/or site creation.

When developing custom site definitions, I find it easier to forgo the declarative mess and staple a custom feature to my custom site definition, allowing me to build the site up with code. Andrew Connell has a blog post to this effect:

http://www.andrewconnell.com/blog/archive/2008/02/15/You-dont-need-to-create-site-definitions.aspx

( Disclaimer : yeah, it's old, but still quite relevant, in my opinion)

Now that your tasks are programmatic (allowing you to debug, log errors, and generally have more visibility into the SharePoint magic) you can initialize your new SPWeb object as you see fit via the SharePoint object model.

  1. Setting the available page layouts .
  2. Setting your custom page as the homepage (after you add it to the Pages library).

Perhaps someone else can enumerate 100% declarative approach; I'm sure it's ugly, as is most CAML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM