Question

I've done a fair amount of looking into this idea without promising leads.

Let me define my problem:

I need to add a third column (as a Web Part Zone) to the "My Newsfeed" page in My Sites. The problem is SharePoint Designer will not be available (which comprises 90%+ of the solutions I've found for this problem) and I do not have access to the master page... which limits me to say the least.

Here's what I've dug up so far:

Now, it appears that in order for the page to persist the web part zone I can't just add it willy-nilly ( Using C# ) and it must be added before the PreInit() event in the page cycle (if added programmatically) on every request ( Addressing Page Cycle ) and the recommended method is by altering the code on the page to include an additional asp:ContentPlaceHolder tag ( hence all, the SharePoint, Designer solutions ).

So finally:

I'd like to do this via PowerShell once if possible (a la this link was trying to do-ish). Does anyone have suggestions on this?

Was it helpful?

Solution

If another company is creating those pages, and your client needs /asks you to put in that extra column, have them ask the other comnpany to add that extra column (and perhaps some javascript to hide it if it does not contain any webparts)?

Update:

Ok, the following worked for me:

  • Get a copy of the out of the box default.aspx for the My Site Host site template, found in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\SiteTemplates\SPSMSITEHOST and save it somewhere on disk so you can edit it.
  • Open the file, (don't scream, but the HTML is a complete disaster :-D, I cleaned it up)
  • (After cleaning up the HTML,) add the needed extra column in the tr with id MiddleRow, copy the html from 1 of the other columns already there, give the new zone a unique ID and change the width of the 3 TD's containing the zones:

    <td style="padding:10px">&nbsp;</td>
      <td valign="top" ID="MiddleOuterRightCell" width="25%"> 
        <WebPartPages:WebPartZone runat="server" FrameType="TitleBarOnly" AllowPersonalization="true" ID="MiddleOuterRightZone" Title="Outer right zone" Orientation="Vertical">
           <ZoneTemplate></ZoneTemplate>
         </WebPartPages:WebPartZone>
         &nbsp;
     </td>
    <td style="padding:10px">&nbsp;</td>
    

Now for the actual file overwrite (I did this in a small console app, but of course you can use for instance a FeatureReceiver, or PowerShell):

using (var site = new SPSite("http://mysitehosturl"))
{
  var file = site.RootWeb.RootFolder.Files["default.aspx"];
  file.CheckOut();

  var newFile = File.OpenRead(@"d:\test\default.aspx"); // change path
  file.SaveBinary(newFile);
  file.CheckIn("overwrite with new layout");
}

Clean default.aspx: http://www.dcubed.nl/MySiteHostDefaultAspxClean.zip

OTHER TIPS

Good Solution: Make neogitation for business users to allow changes and use another (3 columns) master page for this. This is SharePoint default mechanism for achieving this

Possible workaround: Use custom HttpModule and dynamicaly redirect users to the new master page with additional column. Example

One option would be to make a copy of the physical file in the 14-hive from any SharePoint installation, adapt it in your solution and REPLACE the original via a solution package deployment. The obvious downside is that product updates might overwrite it!

If you need to customize 14 Hives pages you can replicate the 14 hives dir and point your vdir to that 14 hives dir. Remember to backup files prior to patching. This is supported by Microsoft.

Ditto: https://sharepoint.stackexchange.com/a/35483/3569

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top