I want to remvoe the +add new document link from the top level of the library and have it show up under each document set to upload documents to the document set.
2 Answers
To remove the link from the top level view, edit the page (Site Actions -> Edit Page) and then edit the list view webpart. In the web part properties panel, you can choose a toolbar type of "No Toolbar".
To add an upload link to the inside of a document set is a bit trickier. One option is to add a content editor web part that embeds JavaScript on the page to automatically generate the upload link for you.
In SharePoint 2010, the best way to achieve this is by putting your HTML/JavaScript in a text file and uploading it to a library on your site. Then when you add a content editor web part to a page, you can set its "Content Link" property to be the URL of your uploaded text file.
Here's an example of some JavaScript you could use to add the "add new document" link to the welcome page of a document set (replace yoursharepointenvironment.com
with the URL of your environment, and set contentTypeId
to the ID of your document set content type):
<script>
function buildUrl(webUrl, listId, root, folder){
var contentTypeId = "0x010100E035095DF31D774A89CF934B42C6110D";
return "http://yoursharepointenvironment.com" + webUrl + "/_layouts/Upload.aspx?List=" + escapeProperly("{"+listId+"}") + "&RootFolder=" + encodeURIComponent(root +"/" + folder) + "&ContentTypeId="+contentTypeId+"&Source=" + escapeProperly(window.location.href);
}
ExecuteOrDelayUntilScriptLoaded(function(){
var clientContext = new SP.ClientContext();
var web = clientContext.get_web();
var list = web.get_lists().getByTitle("Work Efforts");
var root = list.get_rootFolder();
var item = list.getItemById(GetUrlKeyValue("ID"));
clientContext.load(web);clientContext.load(list);clientContext.load(root);clientContext.load(item);clientContext.executeQueryAsync(
function(){
var webUrl = web.get_serverRelativeUrl();
var folder = item.get_item("FileLeafRef");
var listId = list.get_id().toString();
var rootFolder = root.get_serverRelativeUrl();
var link = document.getElementById("customAddDocument");
var url = buildUrl(webUrl,listId,rootFolder,folder)
link.href = url;
(function(url,link){
link.onclick = function(){
var options = SP.UI.$create_DialogOptions();
options.url = url;
options.dialogReturnValueCallback = function(result){
if(result === SP.UI.DialogResult.OK){
window.location.href = window.location.href;
}
};
SP.UI.ModalDialog.showModalDialog(options);
return false;
}
})(url,link);
link.style.display = "inline-block";
document.getElementById("customAddDocumentImage").style.display = "inline-block";
},
function(){
alert(args.get_message());
}
);
},"sp.js");
</script>
<SPAN class="s4-clust" id="customAddDocumentImage" style="display:none; OVERFLOW: hidden; HEIGHT: 10px; WIDTH: 10px; POSITION: relative;"><IMG style="POSITION: absolute; LEFT: 0px !important; TOP: -128px !important" alt="" src="/_layouts/images/fgimg.png"></SPAN>
<A style="display:none;" id="customAddDocument" class="ms-addnew">Add new document</A>