1 / 18

Who am I?

Who am I?. Anders Rask SharePoint Solution Architect, ProActive A/S Community moderator on sharepoint.stackexchange.com. @AndersRask. http://dk.linkedin.com/in/arask. http:// sharepoint.stackexchange.com. http://sites.wizdim.com/andersrask. Developing Custom Web Templates.

dash
Download Presentation

Who am I?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Who am I? Anders Rask SharePoint Solution Architect, ProActiveA/S Community moderator on sharepoint.stackexchange.com @AndersRask http://dk.linkedin.com/in/arask http://sharepoint.stackexchange.com http://sites.wizdim.com/andersrask

  2. DevelopingCustom Web Templates In Visual Studio 2010 #spsuk30

  3. Web Templates? • Web Templates is a new site provisioning method in SharePoint 2010 that, amongst other things, can be used with MSOL since it can be deployed as a Sandboxed Solution • Relatively unknown, probably due to little attention from product group • Should be used when ever possible for branding SharePoint 2010!

  4. Template Provisioning methods • Site Templates • Site Definitions • Feature Stapling • Provisioning Providers • WebProvisioned event • Web Templates

  5. Site Templates • A ”light” version of Web Templates. • (Most) sites can be saved as template • In SP2010 theyare WSP solutions (not STP files) • Can beimportedinto Visual Studio to become ”real” Web Templates

  6. Custom Site Definitions • Defacto way of customizing SharePoint in SP2007 • Many opinions on how (and if) to usethem • Best Practice to keep site def’s slim (get ID and use feature stapling) • That means no modules in ONET.XML and as few features as possible

  7. Feature Stapling • Makes it possible to associate (staple) functionality to existing site definitions when site is being provisioned • <FeatureSiteTemplateAssociation Id=”[guid]>" TemplateName="BLANKINTERNET#0" /> • Can also have feature properties • Scope is usually Farm, but can also be WebApp or Site • To associate to all templates (except Blank) use Global

  8. Provisioning Providers • ”Hotwires” site provisioning, by only creating site collection and database, but not apply template • In code you then apply any template, and then apply any logic • Example: Activate features, restrict sub-templates, create subsites, set security, create groups, add web parts... classMeetingWorkspaceProvisioningProvider : SPWebProvisioningProvider { publicoverridevoid Provision(SPWebProvisioningProperties properties) { SPWeb site = properties.Web; string xmlPath = properties.Data; // provision Blank Meeting Template site.ApplyWebTemplate("MPS#1"); // do something potentially useful here } }

  9. WebProvisioned event receiver • Gives you a hook into the provisioning process to execute arbitrary code. • Event is asynchronous (but a good idea to set to Synchronous to avoid race conditions) • Receiver can have Site or Web scope • Site: called for every sub-site created in the site collection • Web: called only for the sub-sites that are immediate children of the site where receiver is called • Usage example: set Theme on sub-sites, add web parts... etc publicoverridevoidWebProvisioned(SPWebEventProperties properties) { ThmxTheme theme = ThmxTheme.Open(properties.Web.Site, ThmxTheme.GetThemeUrlForWeb(properties.Web.ParentWeb)); theme.ApplyTo(properties.Web, false); properties.Web.Update(); base.WebProvisioned(properties); }

  10. Web Templates • Created in Visual Studio as Element • No direct tool support yet, but not much to it… • Custom ONET is injected instead of referenced site definition, so no link to provisioned sites • Scope can be Site (Sandboxed Solution) or Farm (Trusted solution) • Supports publishing framework

  11. What provisioning method is right? • Use the right tool for the job • Often a combination is the right solution. • The customizations you want to do often dictates approach. • Use Web Templates whenever possible! ”It Depends!”

  12. Time for… DEMO!

  13. Common ”gotcha’s” creating Web Templates • Since stapling is not supported, be aware that features that would normally be stapled on an OOB site definition must be activated manually (e.g. Taxonomyfield feature) • Web Template and the element it resides in must have same name • If your Web Template has site scoped features, you must ensure these are activated when using template on sub-webs • When provisioning sub-webs with PowerShell using Sandboxed Solutions you need to provision in two steps: 1) Create web, 2) Apply template • Known issues: • Doesn’t work with variations and content publishing • Subweb and Locale doesn’t work! • Bug if OS regional settings and installed language isn’t the same and provisioning “outside of UI” (Visual Studio or PowerShell) • “Race conditions” with Content Type provisioning (CT hub)

  14. Good Web Template practices • Save the custom template name in a property bag on the SPWeb for future reference • Ensure your site scoped features for example by calling them from web feature in ONET.XML • Use Visual Studio –not save Site as Template- to create Web Templates • Check what features are normally stapled to the OOB site definition you are mimicking and add them last at appropriate scope in ONET.XML

  15. Keytake-aways • Web templates is just a new way of provisioning sites in SharePoint 2010 • Preferthem over Site Definitions 99% of the time: • B2B upgrades is easy (no link to manifest) • V2V upgradeswillbeeasier • Works on SharePoint Online • Scope is either Site (Sandbox) or Farm (Trusted) solutions • Does not work with Site Variations, Content Publishing or similar sites where template selection is out of yourcontrol (think Meeting templates, My Sites etc)

  16. References Mirjam van Olst: Using Web Templates to create Site Collections http://yux.dk/1a Supported and unsupported scenarios for working with custom site definitions http://yux.dk/1b Vesa Juvonen: SharePoint 2010 and web templates http://yux.dk/1c Robert Bogue: Understanding SharePoint Branding Options http://yux.dk/1d Brian Wilson: Site Definitions versus Site Templates and deciding on the correct customization approach http://yux.dk/1e New Event Binding Functionality in SharePoint Foundation 2010 http://msdn.microsoft.com/en-us/library/ee539983.aspx

  17. Thanks for attending session! Thanx for attending! See you at http://sharepoint.stackexchange.com

  18. Visual Studio 2010 SharePoint Power Tools Templates and extensions that provide a sandboxed Visual Web Part together with enhanced support for sandboxed compilation to help you develop SharePoint solutions even more productively. http://visualstudiogallery.msdn.microsoft.com/8e602a8c-6714-4549-9e95-f3700344b0d9 • Mavention Cancel Adding SharePoint Project Items Disables the default behavior of automatically adding SharePoint Project Items to Features. http://visualstudiogallery.msdn.microsoft.com/9c7c4a73-3558-4712-a65c-badf070e4abc • CKS - Development Tools Edition (Server) The SharePoint 2010 Visual Studio 2010 Extensions project (CKSDEV) is a collection of Visual Studio templates, Server Explorer extensions and tools providing accelerated SharePoint 2010 development based on Microsoft's new SharePoint 2010 development tools. http://visualstudiogallery.msdn.microsoft.com/ee876627-962c-4c35-a4a6-a4d89bfb61dc • ImtechGetSPMetal Definition Extension Installs a Site Node Extension that allows you to generate the SPMetal Definition from the given SharePoint Site. http://visualstudiogallery.msdn.microsoft.com/1a7fc8c2-8cdb-414b-b7bb-9c25897bf78b

More Related