Monday, November 26, 2012

Display Sublevel menus for Global Navigation in Sharepoint 2010

To display the Sub level menus as one shown below
 
Follow these below steps.

Open the site in Sharepoint Designer 2010

  1. Open your Master page for the portal say "v4.master" or "v4_Custom.master" (in case you have a custom master page created for your site)
  2. Find for the keyword "Orientation" 
  3.  
  4. Edit the values for "StaticDisplayLevels" and "MaximumDynamicDisplayLevels" as per your requirement. Initial value for "MaximumDynamicDisplayLevels" would be 1 and you can change it to 2 for the menu to appear as  shown in the above image

Wednesday, November 21, 2012

Display BreadCrumbs for Sharepoint 2010 sites


If you want the breadcrumb to appear in proper way, that shows the root site followed by subsite and so on, you can add the below line of codes in your master pagewhich the site is referring to.

    <asp:ContentPlaceHolder id="PlaceHolderSiteName" runat="server">
                                            <asp:sitemappath runat="server" sitemapproviders="SPSiteMapProvider,SPXmlContentMapProvider" rendercurrentnodeaslink="true" nodestyle-cssclass="breadcrumbNode" currentnodestyle-cssclass="breadcrumbCurrentNode" rootnodestyle-cssclass="breadcrumbRootNode" hideinteriorrootnodes="true">
</asp:sitemappath>                                   
                                            </asp:ContentPlaceHolder>

Sunday, August 26, 2012

SharePoint 2010: Show QuickLaunch in web part page.

  1.   Remove this place holder from webpart page

< asp:Content ContentPlaceHolderId="PlaceHolderNavSpacer" runat="server"></asp:Content>
< asp:Content ContentPlaceHolderId="PlaceHolderLeftNavBar" runat="server"></asp:Content>


2 Remove below code from web part page


<SharePoint:UIVersionedContent ID="WebPartPageHideQLStyles" UIVersion="4" runat="server">
<ContentTemplate>
<style type="text/css">
body #s4-leftpanel {
display:none;
}
.s4-ca {
margin-left:0px;
}
</style>
</ContentTemplate>
</SharePoint:UIVersionedContent>

Tuesday, February 21, 2012

Programmatically applying themes


//Open site collection object
using (SPSite mySite = new SPSite("http://SiteUrl"))
{

// Open site
using (SPWeb oWeb= mySite .OpenWeb())
{
oWeb.ApplyTheme("<theme to be applied>");
oWeb.Update();
}
}

Sunday, February 5, 2012

Programmtically list all attachements in a List

public void fnListAttachments(string site, string listName)
{
    StringBuilder strAttachNames= new StringBuilder();
    using (SPSite oSite = new SPSite(site))
    {
        using (SPWeb oWeb = oSite.OpenWeb())
        {
            SPList oList = oWeb.Lists[listName];

            SPListItemCollection oListItems = oList.Items;
            foreach (SPListItem item in oListItems)
            {
                SPAttachmentCollection attachmentscol= item.Attachments;

                if (attachmentscol.Count <= 0) return string.Empty;

                foreach (var attachment in attachmentscol)
                {
                    strAttachNames.Append(attachment.ToString());
                }
            }
        }
    }
    //return strAttachNames.ToString();
}

Feature handler to save documents to physical folder

  SPSite site = new SPSite(properties.SiteId);
        using (SPWeb web = site .OpenWeb()) {

            string folderName = "";
            SPFolder cols = web.Folders[site.Url + "/TestDocumentLib"];

            SPList list = web.Lists["TestDocumentLib"];
            SPDocumentLibrary docLibrary = (SPDocumentLibrary)list;
            SPListItem listItem = docLibrary.GetItemById(properties.ListItemId);

            SPFile file1 = web.GetFile(listItem.UniqueId);
            string strUrl = file1.ServerRelativeUrl.ToString();
            string destinationFolderUrl = @"C:\Documents and Settings\Documents\";
            byte[] binfile = file1.OpenBinary();
            string strRootUrl = list.RootFolder.ServerRelativeUrl.ToString();


            int count = strUrl.Split('/').Length - 1;
            string[] str = strUrl.Split('/');

            for (int i = 1; i < count; i++)
            {
                destinationFolderUrl += str[i] + "\\" + folderName;
            }
            SPSecurity.RunWithElevatedPrivileges(delegate()
           {
               if (!(Directory.Exists(destinationFolderUrl)))
               {

                   Directory.CreateDirectory(destinationFolderUrl);

                   FileStream fstream = System.IO.File.Create(destinationFolderUrl + "\\" + file1.Name);
                   fstream.Write(binfile, 0, binfile.Length);
                   fstream.Close();
               }
               else
               {
                   //Directory.CreateDirectory(destinationFolderUrl);
                   FileStream fstream = System.IO.File.Create(destinationFolderUrl + "\\" + file1.Name);
                   fstream.Write(binfile, 0, binfile.Length);
                   fstream.Close();
               }

           });
        }
}

Wednesday, January 11, 2012

List Template IDs

List template nameListTemplateID
NoListTemplate0
GenericList100
DocumentLibrary101
Survey102
Links103
Announcements104
Contacts105
Events106
Tasks107
DiscussionBoard108
PictureLibrary109
DataSources110
WebTemplateCatalog111
UserInformation112
WebPartCatalog113
ListTemplateCatalog114
XMLForm115
MasterPageCatalog116
NoCodeWorkflows117
WorkflowProcess118
WebPageLibrary119
CustomGrid120
SolutionCatalog121
NoCodePublic122
ThemeCatalog123
DataConnectionLibrary130
WorkflowHistory140
GanttTasks150
Meetings200
Agenda201
MeetingUser202
Decision204
MeetingObjective207
TextBox210
ThingsToBring211
HomePageLibrary212
Posts301
Comments302
Categories303
Facility402
Whereabouts403
CallTrack404
Circulation405
Timecard420
Holidays421
IMEDic499
ExternalList600
IssueTracking1100
AdminTasks1200
HealthRules1220
HealthReports1221
InvalidType-1

A sales engineer is someone who promise you a bridge, even when there's no river.