Showing posts with label Sharepoint Context Menu. Show all posts
Showing posts with label Sharepoint Context Menu. Show all posts

Tuesday, March 31, 2009

Iterating through All the Folders in your Sharepoint Site

Recently I got a request from a client to get a report of the number of items they had in the document libraries on their site. They wanted it broken down with the number of files per site, document library, and eventually per folder. Anyways its a fairly simple procedure (or so I think anyways), but figured I’d post it up since its been a while since I’ve thrown anything up. The code is broken into two methods, the first is used to iterate through all the child webs of a given SPWeb and also iterates through all the lists for that web and then calls the second method to interate through all the folders in a given list.

public void CrawlWeb(SPWeb web)
{
foreach (SPList list in web.Lists)
{
CrawlFolder(list.RootFolder);
}

foreach (SPWeb subWeb in web.Webs)
{
CrawlWeb(subWeb);
}
}

public void CrawlFolder(SPFolder folder)
{
if (folder != null && folder.Name.CompareTo(“forms”) != 0)
{
foreach (SPFolder subFolder in folder.SubFolders)
{
CrawlFolder(subFolder);
}
}
}

Tuesday, March 17, 2009

adding a new menu Item in Sharepoint. (SharePoint Features)

WSS 3.0 - How to create new SharePoint Feature?
How to create New Feature in WSS 3.0? / MOSS 2007

How to add new menu item under “Site Settings” menu in wss 3.0?

1. Create a new folder, called “SabinsNewFeature”, in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES

2. Create an Xml file, called “feature.xml” in the “MyListUserFeature” folder
3. Edit the feature.xml file and add the following content


Title="Feature My List User Feature"
Description="Custom action on Site Actions"
Version="1.0.0.0"
Scope="Site"
xmlns="http://schemas.microsoft.com/sharepoint/">





4. Replace the GUID placeholder in the previous Id attribute, generate a GUID by running guidgen.exe, located in Local_Drive:\Program Files\Microsoft Visual Studio 8\Common7\Tools.

Create an Xml file, called “ListUsers.xml” in the “SabinsNewFeature” folder

5. Edit the file and add the following content


GroupId = "SiteActions"
Location="Microsoft.SharePoint.StandardMenu"
Sequence="1000"
Title="List Users">



6. Install the new feature by running the following command by going to Start>Run>cmd

change to the following directory: %COMMONPROGRAMFILES%\Microsoft shared\Web server extensions\12\Bin. (Because, STSADM.EXE sits in this folder )

Execute the following command from the above location

Stsadm –o installfeature –filename SabinsNewFeature\feature.xml

You will get a message saying "Operation completed Successfully"

7. Activate the new feature by running the following command
stsadm –o activatefeature -filename SabinsNewFeature\feature.xml -url http://siteurl

if your site has been in the port,
stsadm –o activatefeature -filename SabinsNewFeature\feature.xml -url http://siteul:port number


Now you will see the new menu item in the "Site Settings" of the site that you installed the feature.