
This describes how to add a custom menu to a document library.
Adding the Web Part to a Page
In SharePoint, navigate to a page with a document library web part on it, or add one to an existing page.
On the Modify Shared Page menu, point to Add Web Parts and click on Browse.
Drag the Content Editor Web Part from the tool pane onto the page, then click Open Tool Pane link in the web part.
In the Layout section clear the Visible on Page checkbox. This means the web part is not visible to the end-user, but the script we add to the web part is still delivered to the client browser. In the page design view, you can still see the web part, but it is marked as hidden. If you wish you can also change the title of the web part in the Appearance section of the tool pane.
From the tool pane, open the Source Editor and insert the following script:
function Custom_AddDocLibMenuItems(m, ctx)
{
var strDisplayText = "Custom Menu!";
var strAction = "alert('Custom Menu!')";
var strImagePath = "";
// Add our new menu item
CAMOpt(m, strDisplayText, strAction, strImagePath);
// add a separator to the menu
CAMSep(m);
// false means that the standard menu items should also be rendered
return false;
}
script language="javascript" should precede these codes
function Custom_AddDocLibMenuItems(m, ctx)
{
var strDisplayText = "Custom Menu!";
var strAction = "alert('Custom Menu!')";
var strImagePath = "";
// Add our new menu item
CAMOpt(m, strDisplayText, strAction, strImagePath);
// add a separator to the menu
CAMSep(m);
// false means that the standard menu items should also be rendered
return false;
}
script language="javascript" should precede these codes
and closing scripts tag should proceede it.
Click Save in the Source Editor, and then click OK in the tool pane.
Now test the web part by opening a document library drop-down menu on the same page. You should see the new menu item at the top of the menu with a separator bar splitting it from the rest of the menu
Click Save in the Source Editor, and then click OK in the tool pane.
Now test the web part by opening a document library drop-down menu on the same page. You should see the new menu item at the top of the menu with a separator bar splitting it from the rest of the menu
No comments:
Post a Comment