Page Layout Shenanigans

I’ve been working on a full trust SharePoint 2010 solution that uses a module to deploy some page layouts to the master page gallery and ran into an interesting scenario…

Setting the scene

I have a feature (version 1) that deploys two page layouts.

Activating the feature deployed the page layouts to the master page gallery as expected:

  • Layout1.aspx (deployed by the feature)
  • Layout2.aspx (deployed by the feature)

Then I manually uploaded an additional page layout to the master page gallery:

  • Layout1.aspx (deployed by the feature)
  • Layout2.aspx (deployed by the feature)
  • Layout3.aspx (uploaded manually)

The problem

Later I updated my feature code (version 2) to deploy an additional two page layouts called Layout3.aspx and Layout4.aspx.

The feature upgrade completed successfully and now the master page gallery contains all four page layouts as specified in version 2 of the feature:

  • Layout1.aspx (deployed by the feature)
  • Layout2.aspx (deployed by the feature)
  • Layout3.aspx (uploaded manually)
  • Layout4.aspx (deployed by the feature)

At this point the problem is that Layout3.aspx still uses the page layout that was manually uploaded (stored in the content database) and not the page layout deployed by the feature (store in the SharePoint root).

Un-ghost in the machine

My initial thought was that in order to point the list item at the page layout deployed by the feature to the SharePoint root we can un-customize the page.

Page layouts can be un-customized via the UI by going to the reset to site definition page (site actions > site settings > site actions > reset to site definition) or using code and calling the SPFile.RevertContentStream method.

Attempting to reset (un-customize) Layout3.aspx presents the following error however:

Cannot revert to the site definition version of this file. It is a custom file and is not part of the site definition.

I confirmed that Layout3.aspx had been deployed to the feature folder in the SharePoint root and it is possible to reset all the other page layouts in this way.

Digging deeper

It was time to fire up SharePoint Manager 2010 and look at the actual items in the master page gallery to determine how things work under the hood…

Looking at the page layout items in the master page gallery there are two properties of interest regarding the “customization” of pages:

The CustomizedPageStatus property is used to indicate whether an item has been customised from its definition and can be set to none, customised or uncustomized.

For Layout3.aspx this property is set to “none” whereas the working page layouts it is set to “uncustomized”.

The vti_setuppath property is set to the path of the file in the SharePoint root.

For Layout3.aspx this property was NOT set indicating that the page layout has no file in the SharePoint root.

These two properties are the reason for the exception when attempting to reset the page layout.

Now we just need to set the CustomizedPageStatus and vti_setuppath properties and we’re off to the races but as it turns out they are read-only so we need to find another way.

Solution

After the long windy road of getting here I chose to use the following technique to “repair” these properties on the Layout3.aspx page layout:

I added another upgrade (version 3 for those keeping count) to my feature:

  • Added another manifest (elementsV3.xml) to the module to deploy the same page layout with a different name (e.g. “Layout3Fix.aspx”).
  • Added a custom upgrade action that uses the SPFile.MoveTo method to replace the old Layout3.aspx with the newly deployed Layout3Fix.aspx

Upgrading the feature to version 3 will now replace the manually uploaded page layout (layout3.aspx) with the page layout from the feature. This restores the two properties discussed previously to the correct values and the page layouts now point to those deployed by the feature in the SharePoint root.

Future updates to the page layouts by solution updates will now be reflected in content pages that use these page layouts.

Advertisements

Getting started with apps for Office and SharePoint 2013

I’m starting my journey into the new apps model for Office and SharePoint and so far the documentation at http://dev.office.com has been pretty good. It’s also become clear that I can no longer ignore www.oauth.net :-p

I would suggest starting with these great, free videos:

  • Module 1: Introduction to Office 2013 and SharePoint 2013 development
  • Module 2: Develop apps for Office 2013
  • Module 3: Create document-based apps for Office 2013
  • Module 4: Create mail apps for Outlook 2013
  • Module 5: SharePoint 2013 app model for developers
  • Module 6: SharePoint 2013 developer tools
  • Module 7: Create hosted apps in SharePoint 2013
  • Module 8: Create cloud-hosted apps for SharePoint 2013
  • Module 9: SharePoint 2013 client object model (CSOM) and REST APIs
  • Module 10: OAuth and application identity in SharePoint 2013
  • Module 11: Develop SharePoint 2013 remote event receivers
  • Module 12: Workflow changes and features in SharePoint 2013
  • Module 13: Business connectivity services changes in SharePoint 2013
  • Module 14: Search features and changes in SharePoint 2013
  • Module 15: Enterprise content management changes in SharePoint 2013
  • Module 16: Social features in SharePoint 2013
  • Module 17: Office services in SharePoint 2013
  • Module 18: Create mobile apps for SharePoint 2013
  • Module 19: Project Professional 2013 training for developers
  • Module 20: Project Server 2013 training for developers

http://msdn.microsoft.com/en-gb/office/apps/fp123626

Office 2013 preview crashing after update

If you’re running Windows 8 with Office 2013 preview and you restarted your machine recently you might notice that Word crashes when you open your existing documents.

It seems that something in the latest round of windows updates isn’t playing along. Luckily the fix is easy and only takes a few minutes and a reboot:

  1. Press the windows key
  2. Press CTRL + W
  3. Type “add”
  4. Launch Add or remove programs
  5. Highlight Microsoft Office 2013 Preview
  6. Click Change
  7. Choose Repair

 When the repair is finished and you are prompted reboot the machine and you should be back in action.

Office 2013: The file is corrupt and cannot be opened

I’ve been running my main work machine on Windows 8 and Office 2013 preview for about two weeks now.

I’ve noticed that when I open a office document from an email attachment or a download I get the following message in Office:

This message is not necessarily correct and could be caused by a “blocked” file… this is because the file came from “another computer” and you have to explicitly indicate that its okay:

  1. Right-click the file
  2. Select properties
  3. Click the Unblock button
  4. Click OK

You should now be able to open your file as you would expect now.

Windows Phone “Mango” and Google Calendar

I’ve recently updated my Samsung Omnia 7 to Windows Phone 7.5 (Mango) and found a little bug:

I sync a Google Calendar to my phone and since the update I’ve noticed that when I create items on my phone they don’t sync back to the Google Calendar.

The solution is simple: You need to set the account on your phone to sync both Calendar AND Email.

This is somewhat annoying as I don’t use Gmail but it solves the problem until Microsoft issues a fix.

wp_logo

SharePoint 2010 Service Reference

Mostly for my own reference but here is the list of SharePoint 2010 Windows Services:

Service Description
SPAdminV4 SharePoint 2010 Administration
SPSearch4 SharePoint Foundation Search V4
SPTimerV4 SharePoint 2010 Timer
SPTraceV4 SharePoint 2010 Tracing
SPUserCodeV4 SharePoint 2010 User Code Host
SPWriterV4 SharePoint 2010 VSS Writer
OSearch14 SharePoint Server Search 14
DCLauncher14 Document Conversions Launcher
DCLoadBalancer14 Document Conversions Load Balancer
WebAnalyticsService Web Analytics Service

SharePoint site template reference

When working with SharePoint data from STSADM operations, PowerShell cmdlets or when programming against the SharePoint object model it won’t be long until you need to deal with the internal names for site templates.

I’ve pulled together the default templates that are installed with SharePoint 2010 and 2007 in the following reference:

SharePoint Foundation 2010

Template Name
BLOG#0 Blog
MPS#0 Basic Meeting Workspace
MPS#1 Blank Meeting Workspace
MPS#2 Decision Meeting Workspace
MPS#3 Social Meeting Workspace
MPS#4 Multiple Meeting Workspace
SGS#0 Basic Group Work Site
SGS#1 Blank Group Work Site
STS#0 Team Site
STS#1 Blank Site
STS#2 Document Workspace
WIKI#0 Wiki

SharePoint Server 2010

Template Name
ACCSRV#1 Assets Web Database
ACCSRV#3 Charitable Contributions Web Database
ACCSRV#41 Contacts Web Database
ACCSRV#5 Projects Web Database
BDR#0 Document Center
BICENTERSITE#0 Business Intelligence Center
BLANKINTERNET#2 Publishing Site With Workflow
BLANKINTRANETCONTAINER#0 Publishing Portal
CMSPUBLISHING#0 Publishing Site
ENTERWIKI#0 Enterprise Wiki
OFFILE#1 Records Center
SPSMSITE#0 Personalization Site
SPSMSITEHOST#0 My Site Host
SRCHCEN#0 Enterprise Search Center
SRCHCENTERFAST#0 FAST Search Center
SRCHCENTERLITE#0 Basic Search Center
VISPRUS#0 Visio Process Repository

Windows SharePoint Services 3.0

Template Name
BLOG#0 Blog
MPS#0 Basic Meeting Workspace
MPS#1 Blank Meeting Workspace
MPS#2 Decision Meeting Workspace
MPS#3 Social Meeting Workspace
MPS#4 Multiple Meeting Workspace
STS#0 Team Site
STS#1 Blank Site
STS#2 Document Workspace
WIKI#0 Wiki

SharePoint Server 2007

Template Name
BDR#0 Document Center
BLANKINTERNET#0 Publishing Site
BLANKINTERNET#1 Press Releases Site
BLANKINTERNET#2 Publishing Site with Workflow
BLANKINTERNETCONTAINER#0 Publishing Portal
CENTRALADMIN#0 Central Admin Site
CMSPUBLISHING#0 Publishing Site
GLOBAL#0 Global Template
OFFILE#1 Records Center
OSRV#0 Shared Services Admin Site
PROFILES#0 Profiles
SPS#0 SharePoint Portal Server Site (Obsolete)
SPSCOMMU#0 Community Area Template (Obsolete)
SPSMSITE#0 Personalization Site
SPSMSITEHOST#0 My Site Host
SPSNEWS#0 News Site (Obsolete)
SPSNHOME#0 News Site
SPSPERS#0 SharePoint Portal Server Personal Space
SPSPORTAL#0 Collaboration Portal
SPSREPORTCENTER#0 Report Center
SPSSITES#0 Site Directory
SPSTOC’#0 Contents Area Template (Obsolete)
SPSTOPIC#0 Topic Area Template (Obsolete)
SRCHCEN#0 Search Center with Tabs
SRCHCENTERLITE#0 Search Center
SRCHCENTERLITE#1 Search Center

Other than the native site templates there are also a few others which I’ve frequently encountered in SharePoint environments.

Microsoft Project Server integrates with SharePoint and creates sites based on the Project Workspace (PWS#0) template.

And finally… after the release of WSS 3.0 Microsoft made available a number of additional templates called the Fabulous 40 Application Templates.

Fabulous 40 Application Templates

Template Name
Board#0 Board of Directors
BPR#1 Business Performance Reporting
CASE#0 Case Management for Government Agencies
CLASSROOM MANAGEMENT#0 Classroom Management
CLINIC#0 Clinical Trial Initiation and Management
CAS#1 Competitive Analysis Site
DISCUSSION DATABASE#0 Discussion Database
DIM2#1 Disputed Invoice Management
3#1 Employee Activities Site
BENEFITS#0 Employee Benefits Site
FINAL#1 Employee Training Scheduling and Materials
EQUITY2#0 Equity Research
GCHAN_MAN#0 Manufacturing Process Management
IMC2#1 Integrated Marketing Campaign Tracking
NEWSTORE#0 New Store Opening
PRODUCT#1 Product and Marketing Requirements Planning
RFP V2#0 Request for Proposal
SPORTS#0 Sports League
TEAM ROOM SITE#0 Team Work Site
APP#0 Timecard Management