Posts

Showing posts from January, 2012

Metadata navigation for a list

Hi, A new feature in SP 2010 is metadata navigation and filtering which allows users to filter the list or library content by using the metadata. A list owner can use this feature to promote fields on the list as key navigational fields, and users viewing those lists see a filtering user interface (UI) that enables them to filter the current list view to show items with the desired values in those fields. Metadata Navigation and Filtering works with list-level indices to support a seamless browsing experience—even in very large lists that contain tens of millions of items. This feature promotes the use of metadata and tagging by ensuring that, when items are well-tagged across multiple fields, they are inherently more discoverable than list view items that are not tagged. A best article on how to configure this by UI is posted at the Microsoft site here . But being a developer our concern is how difficult this configuration if we want to do it in a feature. Well, answer is its quite ea

Creating Custom Activity feed

Image
Hi all, SharePoint provide a excellent feature under my site which display the recent activities of the user performed recently using Recent Activities web part and for colleagues activities it provides My newsfeed web part. These web parts will show only those activities which users was configured under "Edit My Profile" page. Following is the screen shot of the Out of box activities feeds. In order to create the custom activity feed, There are a sample console application provided by the microsoft SDK SharePoint Server 2010: Activity Feeds Console Application just to register the custom activity feed on the server. Cation: There is no method implemented to delete custom activity once created. So make sure while deploying it on production that you must execute this code of creation once. Only one way to delete the activity feed is from database. For more information visit: Remove Method and Way to Remove Activity Feed Now I am going to share the code which can be used as

Sharepoint silverlight World Analog Clock Webpart

Hi, SharePoint 2010 has built-in support for Silverlight Web Parts, making it easy to get Silverlight applications up and running. But in real scenarios sometime requirement needs more customization then its hard to integrate the requirement with out of box WebPart. In this article I will explain how a SilverLight application can be integrated to the sharepoint webpart. Requirements of WebPart : Analog clock should be displayed to the home page of the site which can be personalized and customizable for the normal user. User can add as many as world clocks as he/she want and set the timezone and able to do basic configuration. following are the key points of the requirnments. Can add multiple clocks to the WebPart. Can display the time only Select desired Time Zone from the list Change clock title Show/Hide seconds hand Show/Hide milliseconds dial Show/Hide tenth seconds dial Explanation: After goggling few I found Bamboo webpart which is pretty fine for me and fits my re

Custom Site Map Web Part using dynamic Asp Menu

Hi, Site Map is a very important feature for the users to have a high level view of all sites and even for cross site navigation. I have implement recently a very basic Site map webpart which iterate through all the site collections with in a web application and display them as a tree view like structure. I am sharing the code which basically contains a visual web part: For Ascx file: <asp:Menu ID="SiteMapMenu" runat="server" StaticDisplayLevels="3" Font-Size="16px" Font-Bold="true" DynamicMenuItemStyle-ItemSpacing="5px" DynamicHorizontalOffset="10" > <StaticSelectedStyle ForeColor="#A5C8E8" BackColor="#A5C8E" /> <StaticMenuItemStyle HorizontalPadding="20px" VerticalPadding="3px" /> <DynamicHoverStyle BackColor="#A5C8E8" /> <DynamicMenuStyle BackColor="#A5C8E8" BorderStyle="Solid" BorderWidth="1px" BorderColor=&

Custom Cross site collection Navigation using user control

Hi, Sometimes the out of box navigation does not provides us the type of navigation wants on the whole application. To make such custom navigation which is consistent throughout many site collection it is batter to create a custom user control and simply register it in to the master page. Applying the same master page on every site collection will do the job. Follow below steps to create the user control: 1) Right click on the project and the click on Add New Item. 2)Then add a User Control. Name it as per the convention. 3)Under the ascx file create any type of control you wana use, I prefer asp menu: <div > <asp:Menu ID="MyTopMenu" Orientation="Horizontal" runat="server"> <StaticMenuItemStyle CssClass="topNavStaticMenuItem"/> <StaticSelectedStyle CssClass="topNavSelectedStaticMenuItem"></StaticSelectedStyle> </asp:Menu></div> 4) Now next step is to populate the menu with the tabs: protected vo

Add a webpart to page using Onet/Feature

Hi, Custom home page is quite common requirement for any development project. This post helps you if you need to add out of box web part to page. This post contains good details how to deploy custom page. The AllUsersWebPart tag allow us to insert a custom/Out of box web part and It also contains few attributes which are used to place web part. Two important attributes are WebPartOrder and WebPartZone attributes. The content of the tag is the dwp (or webpart) of any web part. The tag cloud dwp code example is given below: <AllUsersWebPart WebPartZoneID="Right" WebPartOrder="3">           <![CDATA[<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">                       <Title>Tag Cloud</Title>                       <Description>Displays the most popular subjects being tagged inside your organization.</Description>                       <FrameType>TitleBarOnly</FrameType>                       <Chr

Set Home page of sharepoint sites

Hi, According to the client's requirement, every site must be set as a custom home page other then "Pages/Default.aspx". I have added a site definition using CKSDev tool and add this page using Onet.xml. Next step is to create a feature at web level which should contains following code: SPFolder rootFolder = properties.Web.RootFolder; rootFolder.WelcomePage = "default.aspx"; rootFolder.Update(); This code will also work for any site template.

Add calendar summary view list view webpart

Hi, Sometimes client asked to add list view web part on the home page of the site. Its easy to add this view just by user interface with some little configuration changes. But using the feature you must know the trick to get the summary view of the calender list. Use following code just create a summary view of the list. var calendarlist = web.Lists.TryGetList("Calender"); var webpart = new ListViewWebPart { ListName = calendarlist.ID.ToString("B").ToUpper(), ViewGuid = calendarlist.Views[string.Empty].ID.ToString("B").ToUpper()// Use //String.Empty if you are using SP 2007. }; manager.AddWebPart(webpart, "Middle", 3); Few more things you can perform if you want to do some more modifications in the view 1) To get the BaseViewId '0' simple use the following code: var webpart = new ListViewWebPart { ListName = calendarlist.ID.ToString("B").ToUpper() }; var view = calendarlist.GetUncustomizedViewByBaseViewId(0); 2) To add a new fi

Custom Content Query webpart httpcontext issue

Hi, While working with custom content query webparts, I have faced some unexpected errors while adding or modifying the webpart through code. After exploring some blogs I found that webpart modification required http context information to implement any modification. So before we fetch the page webpart manager, we must define the context information using the below code: if (HttpContext.Current == null) { HttpRequest request = new HttpRequest("", web.Url, ""); HttpContext.Current = new HttpContext(request, new HttpResponse(new StringWriter())); HttpContext.Current.Items["HttpHandlerSPWeb"] = web; } var manager = web.GetLimitedWebPartManager("default.aspx", PersonalizationScope.Shared); var contentQuery = new CustomContentQueryWebpart { Title = "My Webpart", ChromeType = PartChromeType.None }; manager.AddWebPart(contentQuery, "Left", 1); Using the above convention you can avoid most of the unexpected errors related to content q