How To Hide The Add Document Or Add New Item
Yesterday I won my MCC Award (Microsoft Community Contributor) and decided to add this entry as a special gift to the community. This is a simple workaround and I saw a request a couple days back asking to hide the Add Document link after the list of items. In fact, the Add Document may encourage users to upload files from their computers rather than use the create new (select content type). Plus, you still have the upload document or multiple documents from the ribbon.
There are a few ways to do that, one of which is using the browser only – add a CEWP and hide the link using CSS (see this thread for more). A similar approach is to use JQuery and hide the cell that has the Add Document link (again, you add a CEWP, reference the JQ library and add the script (something like $(document).ready(function() { $(‘#WebPartWPQ2 .ms-addnew’).hide();});). If you are doing this on the All Items view page, you will notice that the document library web part loses focus and you have to click inside to show the Library Tools ribbon and switching between views is not as easy as it should be. This is because we have two web parts in the page (even if you hide the CEWP, which you should any way – just check the Hidden property under Layout). It turns out there is another easy and better way – customize the xslt in SharePoint Designer. Select the library (site objects – lists and libraries) and click the view you want to edit (top right). If you want to modify the number of items per page, do it first: List View Tools – Options – Paging (this is not required but if you do it later you will overwrite your custom view).
Now highlight the text “Add Document” and from Design tab (under list view tools), Actions group, select customize item (click the arrow next to customize xslt). Then, switch to code view. The source view should increase by around 80 lines (starts with <xsl>). Locate the line taht starts with <td class=”ms-addnew” and change its style to display:none
Save your page in SPD and check it back in the browser. The Add Document is no longer visible and the view functions as usual.
Note1: If all you have is a web part, you can also set Toolbar Type to “No Toolbar” in the web part properties and that will remove the Add Document.
Note2: yesterday was also the release date for SharePoint Service Pack 1 (check this post from Spence Harbar before you install it)
I’ve followed the instructions above but cannot find the text “Add Document” in the xslt code, nor can I find “ms-addnew” (or “” for that matter). Meanwhile, the Add Document link renders at the bottom of the document library in the browser. Any idea what’s up?