4

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?

2
  • "The problem is SharePoint Designer will not be available"... Will you ask to a butcher to work without a knife? No ? Even if everything that SPD does can also be done with C# or PS, do a flavor for yourself, works with the tools than can help you, or explain your customer why it's foolish. But maybe I don't have to whole picture.
    – Steve B
    Commented Apr 27, 2012 at 13:01
  • 1
    Yeah, this is a complicated business situation involving our company and another both being contracted for separate pieces of the project. And the final branding solution is basically a massive lock down of SharePoint to prevent the users from being able to mess with things... to the point that I had to write a custom web part for them to even do site provisioning and they are limited to one template, and one location for it to be created. It's a bank. What can you say. Commented Apr 27, 2012 at 13:08

4 Answers 4

2
+100

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

7
  • This isn't a bad idea if we had access to the masters. I'm looking for a solution that doesn't involve the master pages. Commented May 4, 2012 at 19:29
  • OK, fired up my dev server and did some checking. The page you are referring to is actually not part of your "own" MySite. It is the homepage for the My Site Host webapp. The webpart zones on it are an actual part of that file (default.aspx) and not some master page. So it is overwritable using code (in for instance a feature receiver, or powershell). Working on an example now
    – Colin
    Commented May 4, 2012 at 21:28
  • I was concerned that overwriting the default.aspx would make the changes to the My Profile page as well, since they use the same template (shareesblog.com/?p=601) but My Profile uses Person.aspx. This is the best answer thus far, but I was looking for a way to add the zone via the Object Model rather than via HTML. This method is subject to the same problem that C. Marius mentioned about Microsoft Updates. You might end up with the points anyhow though. Commented May 7, 2012 at 14:28
  • The fill will not be overwritten by updates, it will be ghosted in the database.
    – Colin
    Commented May 7, 2012 at 16:31
  • Not quite what I was looking for, but this is a valid solution, and it did use the OM... so you win buddy. Commented May 7, 2012 at 17:59
0

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

5
  • 1
    Thanks for the input, but we don't have access to the master page. The master pages / branding are being done by another company. We are just doing the build out and custom web parts. Honestly, my best bet might just be to contact the other company and request that they add this column. Commented Apr 27, 2012 at 13:55
  • Another possibly technical solution is still use HttpModule and change the page structure before it will init.. However you approach is more legit
    – AlexSSE
    Commented Apr 27, 2012 at 14:09
  • If smn downvote, can you plas make a comment at least..
    – AlexSSE
    Commented May 3, 2012 at 7:45
  • The problem with this is it still uses a master. And we still don't have access to these / are not responsible for branding. Also: your link says "Instead, an HttpModule must be configured as an all-or-nothing proposition at the Web application level." This is only on one page (My Newsfeed) of the web application and not the other two (My Content, My Profile). Commented May 4, 2012 at 19:28
  • @rjcup3 Thanks fow clarifications. But still in HttpModule if you know the exact URL you can process only these requests.
    – AlexSSE
    Commented May 5, 2012 at 10:57
0

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!

3
  • It's for the My Newsfeed which uses the same definition as My Profile. One has a third column, the other doesn't. Commented May 4, 2012 at 19:24
  • Plus, as you noted product updates may overwrite this. Commented May 4, 2012 at 19:24
  • yes, but what i mean is copying its source, change in the design time to add necessary changes, keep it to inherit from the same Application page base, but give it a new file name. Once this is done, change the Top navigation bar via Site Settings to point to the NEW one. Because this is shared across all my sites it will be targeted everywhere! Commented May 5, 2012 at 8:51
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.