Saturday, July 10, 2010

SharePoint 2010: Hide Recently Modified Items

In SharePoint 2010 we all are familiar with the following annoying quicklaunch menu:

image

In SharePoint 2010, the recently modified items is one of many less-used feature. In software industry we are familiar with 80-20 principal. If 80% custom wants a feature then we should go with it and if you can satisfy 80% users then you have the successful product. I guess the ‘Recently Modified’ quick link doesn’t even needed by 10% people but the link is enable by default. Maybe this is a security feature to let administrator know what files have been modified recently. But there should have an on/off option as this is less wanted feature and most of the administrators want to hide this link. Justin has already found a way to hide the option by modifying template file as described in his blog. However, we can fix the issue without modifying the shared file. Specially in case of shared hosting we don’t want to modify the files from 14 hive. The two approaches described here is implemented by modifying master page. The first approach is acceptable but may have unknown side effects. On the other hand second approach is much better and less chance of side effects.

 

First solution:

1. Open your master page (default one is V4.master) and find the content place holder ‘PlaceHolderLeftActions’ as shown below:

<asp:ContentPlaceHolder id="PlaceHolderLeftActions" runat="server">                
</asp:ContentPlaceHolder>

2. Now set the content place holder visible property to false. as shown below:

<asp:ContentPlaceHolder id="PlaceHolderLeftActions" runat="server" Visible="false">            
</asp:ContentPlaceHolder>
Why it works?

The above trick works as in the aspx files the recently changed menu is put inside the placeholder. If you open a file in SharePoint Designer  you can find that the recently modified menu is put under the placeholder with id ‘PlaceHolderLeftActions’ as shown below:

<asp:Content ContentPlaceHolderId="PlaceHolderLeftActions" runat="server">
    <SharePoint:RecentChangesMenu runat="server" id="RecentChanges" />
</asp:Content>
Warning

The content placeholder ‘PlaceHolderLeftActions’ mainly used in blog and wiki sites. So if you are using any of this kind of template then hiding the content place holder will hide others related links too. However, I have found that hiding the content placeholder in team site works perfectly.

 

Second and Better Solution

However, the above trick may have side effects, if the same place holder (‘PlaceHolderLeftActions’) is  used by other pages. Another solution (which I think less side effects or no side effects) is to apply a css. As shown in the following screen, the ‘recently modified’ quick launch uses a css class named ‘s4-recentchanges’ (shown with firebug).

image

So we can another property ‘display:none’ to the same css class by adding the following extra attribute to master page’s header section:

<style type="text/css">
    .s4-recentchanges
    {
        display:none;
    }
</style>

You can even put the above section in a css file and refer the file in master page. The following image shows the master page with the css class:

image

44 comments:

  1. Hi,

    i added the CSS in the default.master page with sharepoint designer and saved. But I still see the recently modified pages. What can I do? (or what do I do wrong?)

    ReplyDelete
  2. You need to modify V4.master as this is the default master page for SharePoint 2010.

    ReplyDelete
  3. A million thanks Sohel! It works perfectly.

    Greetings from Holland.

    ReplyDelete
  4. Another option is to put the style into a text file and then link to that text file from a content editor web part.

    ReplyDelete
  5. Elegant. Thank you.

    ReplyDelete
  6. I have edited the v4.master and the default.master... Added BOTH the css display:none fix and the visible="false" fix... it is STILL showing the Recently Modified links. Any other suggestions?

    ReplyDelete
  7. The 2nd solution worked for me. Are you sure you checked in the changes (not being rude, I forgot to at first myself).

    Now I'm wondering about setting up a "Recently Modified" page for those that really want to see the new stuff. Anyone have ideas on how to do it?

    ReplyDelete
  8. How do I "check in the changes"? I never had the v4 page checked out. (I'm currently the only person working on this site, so I haven't been using the check-in/check-out stuff)

    I should mention that the Recently Modified section does not show up on all Sharepoint pages, just the Wiki pages. Is there a Wiki master page I'll have to edit with the same code?

    ReplyDelete
  9. @CBE and Adni,you can navigate to master page gallery by following 'site settings' => 'Master Pages' under Gallaries. Then you can checkin/publish the master page from the master page gallery.

    ReplyDelete
  10. Went for option B, added to my alternate CSS and then re-applied to all sub sites, worked perfectly, thanks from UK.

    ReplyDelete
  11. If i have to hide the recently modified of particular sub site instead of mater page. then i have tried it by using HTML form web part and write code
    .s4-recentchanges
    {
    display:none;
    }

    but it was not saving in that web part. how should i go for this.
    help on this.

    ReplyDelete
  12. I used the second solution. Couldn't be easier, and worked as promised. Thanks!

    ReplyDelete
  13. Thanks a lot! 2d option saves me huge amount of time!

    ReplyDelete
  14. Hi,

    This is just what I'm looking for, but its not working. When i 1st put the Style code in

    .s4-recentchanges
    {
    display:none;
    }

    into the page, the "Recently Mod.." is removed, but then I get a message saying :- "Warning:The HTML source you entered might have been Modified."

    Then the code has been changed to:

    .ExternalClass2DC49AE4B87E482CB12BD96809778AA8 .s4-recentchanges {
    DISPLAY: none

    And the Recently Modified is BACK!

    Can any one tell me what I'm doing wrong?



    Nivaik

    ReplyDelete
  15. You should put the css style in master page not in a particular page.

    ReplyDelete
  16. solo comentar la linea del Left ACTIONS CHILE

    ReplyDelete
  17. WHY NOT ADD AN HTML FORM WEBPART THEN ADD THE CODE... SO STUPID

    ReplyDelete
  18. Add the below code and save as notepad format.
    .s4-recentchanges
    {
    display:none;
    }
    upload it into sharepoint and copy shortcut.
    In your page add content editor webpart and then edit web part ,provide the shortcut path over there.
    It will hide the recently modified.

    ReplyDelete
  19. Thanks Sohel's, you save my ass again!

    ReplyDelete
  20. CONFIRM: This works really well if you don't have access to the master page.

    Add the below code and save as notepad format.
    .s4-recentchanges
    {
    display:none;
    }
    upload it into sharepoint and copy shortcut.
    In your page add content editor webpart and then edit web part ,provide the shortcut path over there.
    It will hide the recently modified.

    ReplyDelete
  21. Heyyyyy it works!!!!
    Thank you so much! =D

    ReplyDelete
  22. Great post!
    The seconds solution works fine.

    Thank you very much!!!!

    ReplyDelete
  23. This is an excellent post and solution(s)--very helpful. The bigger question is, why did MSFT (SharePoint Dev) make this "Recently Modified" feature default to THE TOP of the Quick Launch menu in 2010? At least in 2007 this little-used feature appeared, by default, at THE BOTTOM of the Quick Launch menu, where it belonged.

    In many of the SharePoint Templates, the site owner/designer/builder is given the tools to customize the Launch Menu, to create the UI and User Navigation desired and appropriate for the site; and then--the first time a site end-user navigates to a website page--Recently Modified takes over the top of the menu and ruins the desired UI and User Nav by pushing it down the menu?

    The logical option, instead of code changes required by a SharePoint admin, would be to make Recently Modified appear in the Site Actions > Site Settings > Look and Feel > Quick Launch options, giving the owner/designer/builder the choice of using/displaying or not using/displaying Recently Modified and also the choice to determine where, if it does display, the Quick Launch displays on the menu. The user is given the same options for all other links and headings, so why not Recently Modified.

    This would both 1) put the decision to use Recently Modified in the owner/designer/builder's hands, and 2) relieve SharePoint administrator's from the time-consuming chore of having to come up with code fixes to repair a questionable default (on top) feature.

    ReplyDelete
  24. Sohel,

    I am a SharePoint end user with some HTML knowledge but not a programmer or admin/engineer. On your second, recommended solution, can you clarify for me (for the more technical, probably already clear), but is this CSS fix applied to a Master page that then dictates the same display (Recently Modified, NOT showing) on each page, or is the CSS applied to the HTML of each page. Thanks much!

    ReplyDelete
  25. It's just the change in master page which will result hiding the text from all pages

    ReplyDelete
  26. thankz... a lot.. its working..

    ReplyDelete
  27. Sohel,

    The Admin/Engineer at our company used your Fix #2 to the Master page to eliminate Recently Modified from a couple of my websites. It worked, v. cool, thanks! However, now, when I use Site Actions > Create Page and create a new page, then save, if I try to REopen the page using Site Actions > Edit Page, the command does not work--the page cannot be reopened. What do you think, have you ever seen this? Could the Dev have hosed the Edit Page control when he made the fix?

    ReplyDelete
  28. I have not noticed this problem and I guess the problem is not related to this fix. Please revert the fix and make sure the fix is not the culprit. The fix is just adding a css and supposed not to affect existing functionalities.

    ReplyDelete
  29. Thanks Sohel. Your expertise and generosity in sharing your knowledge are much appreciated!

    ReplyDelete
  30. Awesome thanks alot :)

    ReplyDelete
  31. Brilliant solution regarding linking to an external file from a content editor webpart (it definitely works). Agreed that Microsoft should allow anyone editing a page to remove "Recently Modified" - it's not very useful when you want to show only one language at a time on a bilingual site. No one wants English on a French page or vice versa.

    ReplyDelete
  32. Fantastic, worked a teat

    ReplyDelete
  33. Hi!

    I implemented the 2nd solution and it works for me. But my colleagues still see the "Recenlty Modified" section. How can I hide it for them? Is this related to permissions in any way?

    Thanks!
    Katrin

    ReplyDelete
  34. @Katrin, Do you have more than one master pages used? Could it be the case that you have applied the hack in one master page but not other? If both of you are getting the access the same page and you are seeing the message but other users seeing then surely it's a single master page, either it might be different master page if you are seeing different page.

    ReplyDelete
  35. I used the second option and it worked beautifully! Thank you from Indiana!

    ReplyDelete
  36. I applied this code to the master page:

    s4-recentchanges
    {
    display:none;
    }

    Now I'm getting this:

    Status: Checked out and editable.

    Any suggestions?

    ReplyDelete
  37. Disregard....forgot to Check in the document.

    ReplyDelete
  38. Sohel,
    There is only one master page applied.
    :-( Any other ideas, anyone?

    ReplyDelete
  39. Hi Sohel,

    thanks a lot for the hint! i applied the css to the v4.master and it works perfectly.
    thanks again and have a great day
    Sebastien

    ReplyDelete
  40. Many thanks for the article. I used first solution and it worked brilliantly.

    ReplyDelete
  41. Thanks for this, (second solution) worked a treat.

    ReplyDelete