Fix for broken Sharepoint blog site (post.aspx, default.aspx pages)

In this scenario, the main blog display webpart on the post.aspx page has been deleted. There is no way (in the browser) to restore that webpart. You could try appending ‘_layouts/reghost.aspx’ (see this site, thanks to Stephen of Sharepoint911) to the end of your URL…but that didn’t work for me. Here’s a snapshot of what my post.aspx page looks like (problem re-created).

 

To fix this, it’s a little tricky. First, you’ll need Sharepoint Designer and an unbroken blog (doesn’t matter where it sits). Open up the unbroken blog site in sharepoint designer and follow this file path: All Files > Lists > Posts > Post.aspx (here’s a snapshot).

 

Edit the “Post.aspx” file in advanced mode (checkout shouldn’t matter…you’re just copying some code from it. Find the code just below:

<WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" ID="Left" Title="loc:Left" AllowPersonalization="false">
<ZoneTemplate>

The webpart begins with

<WebPartPages:XsltListViewWebPart runat="server" Description="Use the Posts list for posts in this blog."

(see snapshot below)

 

Copy that entire webpart block. Now go the broken blog’s Post.aspx page. You might notice that right after the “Left” webpartzone, it goes straight into the comment block (because the blog view isn’t there!).

 

In between the <zonetemplate> and the comment webpart, paste the code from the other post.aspx page. Now here’s the tricky part. In sharepoint designer, you should save this file even though it will give you all sorts of errors talking about nonexistent lists and breaking site definitions. Don’t worry. Save it. Next, (while keeping post.aspx open), open up AllPosts.aspx from the same directory. This is to obtain the listids, names, etc.

Locate the webpart just inside the main webpartzone of the AllPosts.aspx page. Open up the tag properties (easier to see in my opinion) and copy the following 3 items: DetailLink, ListId, ListName

 

Go back to Post.aspx and paste them over the properties in the newly pasted webpart that are currently there. This will sync up the new webpart with the correct lists and links for the blog you’re in.

Here’s the catch (for me at least). Save this Post.aspx file to your DESKTOP. Yes. Now go back to All Files > Lists > Posts and click “Import”. Import the file from your desktop and overwrite whatever is there (no need to include the extra docs in the popup). And finally, right click on that newly imported document, reset it to site definition, and Voila!

 

Now that this is fixed, I can use the same concept (importing and resetting as opposed to just saving) to make Heather Waterman’s tip on trimming blog posts work for my default.aspx page. I do wonder if unchecking “Enable Detaching Pages from the Site Definition” in the sharepoint designer settings might be a shorter way around this. I’ll try that next!

About bentedder

Ben Tedder is a front-end web developer. He loves WordPress, SharePoint, and Drupal, along with jQuery, CSS, and good 'ol HTML. +Ben Tedder on Google or follow @bentedder

Comments

I try to respond personally, but things get busy sometimes :)
  1. John says:

    This is very useful. Thank you so much! I don’t know who keeps deleting my webpart but this is easy to fix now!

    • ben @ home says:

      Glad to hear it…also, if you take away “add and customize pages” permissions from your users, they won’t be able to edit the post.aspx page and delete your webparts.

  2. Bas Jacobs says:

    Thanks! Saved me a lot of time. Keep up the good work!

  3. Tom Davidson says:

    Thank you, Internet stranger!

  4. Thanks Ben! This saved the day when somebody had messed up our CEO’s blog site…
    I had to replace the Url of the View tag aswell, but thats a minor.

Join the discussion!