Rkapiljith's Blog

My SharePoint experiments…

How to add additional welcome menu items for SharePoint 2010

Here we will check how to introduce a new menu item to the SharePoint Welcome menu.

  • Open your Visual Studio 2010
  • Create a new project(File >>New>>Project)
  • Select the type as “Empty SharePoint Project” and give a proper solution name “CustomWelcomeMenu”
  • Provide your web URL
  • Select your type as “Farm” deployment
  • Now add a new feature item
  • Give required information to this feature using the design mode. Change the Scope to deploy in “Farm” level

  • Now we change the name of feature file. For doing this from solution explorer we will select the “Properties”
  • Change the name of the feature as required “CustomWM” and press teh enter key. You can see the changes for other files using Solution explorer.

  • Now we need to attach an element to our feature. For doing so we will add a new Element file.

So now if we check our solution explorer we can find our element file get attached to our Feature file.

Now we need to focus on our element file. Use the following code snippet

<?  xmlversion="1.0"encoding="utf-8"?> <  Elementsxmlns="http://schemas.microsoft.com/sharepoint/">   <  CustomAction     Id="customWMItem"     GroupId="PersonalActions"     Location="Microsoft.SharePoint.StandardMenu"     Sequence="1000"     Title="Ente Library"     Description="Open Style Library"     ImageUrl="_layouts/images/KapiljithRajappan.png">     <  UrlActionUrl="~site/Style%20Library"/>   </  CustomAction> </  Elements>

Here i used my own picture which i created using 32×32 KapiljithRajappan.png file and placed in “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES”.

Now we can proceed with the deployment activities. Built the project(F6) and make sure there is no error in the solution. Deploy the same from visual studio and open your Central admin site to see the feature get deployed correctly. This feature is scoped in Farm level. You can change the scope according to your need(site/web/webapp/).

From Central Admin >>System Settings(From Quick links) >>Manage Farm solution.

Since the solution is deployed globally we can see our new expected menu like this from Welcome button.

How to open the Welcome menu links in a Modal Popup Window

Do you wish to open your link in a modal popup dialog window? If so edit your element file and append the UrlAction Url property as

<UrlAction Url="javascript:OpenPopUpPageWithTitle('<Your url to open>',RefreshOnDialogClose,<Your popups Height>,<Your popups Width>,'<Your caption here>')"/>

So here in my case it will look like the below code snippet.

<?xml version="1.0" encoding="utf-8"?>  <Elements xmlns="http://schemas.microsoft.com/sharepoint/">   <CustomAction   Id="customWMItem"   GroupId="PersonalActions"   Location="Microsoft.SharePoint.StandardMenu"   Sequence="1000"   Title="Ente Library"   Description="Open Style Library"   ImageUrl="_layouts/images/KapiljithRajappan.png">   <UrlAction Url="javascript:OpenPopUpPageWithTitle('{SiteUrl}/Style%20Library',RefreshOnDialogClose,800,700,'Kapil Modal Popup Window')"/>   </CustomAction> </Elements> 

Now my output looks like the below snapshot, which is opened in a Modal window.

How to remove links from Welcome Menu

But some of the users may ask us to remove some of the default links from the Welcome menu. So for accomplishing those kind of requirement we will take use of JQuery.

  • Open your master page in SharePoint Designer 2010
  • Make sure you have the JQuery files installed properly to the site
  • Make sure your master page have the proper jQuery reference in master page
<!--START Added by Kapiljith Rajappan for JQuery --> <script type="text/ecmascript" src="/Style Library/JQuery/jquery-1.7.2.min.js"></script> <script type="text/javascript"> if (typeof jQuery == 'undefined') {  document.write(unescape("%3Cscript src='/_LAYOUTS/JQuery/jquery-1.7.2.min.js' type='text/javascript'%3E%3C/script%3E")); } </script> <!--END Added by Kapiljith Rajappan for JQuery -->
  • Add the following code snippet  before the end of </head> tag
<script type="text/ecmascript">  jQuery(document).ready(function($) {  var objects = document.getElementsByTagName("ie:menuitem");  for (var i = 0; i < objects.length; i++)  {       itm = objects[i];   if ($('#' + itm.id).attr("text") == "Sign in as Different User")   {    $('#' + itm.id).remove();   }  } });    </script>
  • Save and publish the master page
  • This will remove the menu item “Sing in as Different User“.

Another workaround for this would be making changes direct to the welcome.ascx file. You can find the file from the location  “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES“.

  • Open the file in any text editor
  • Add the attribute visible=”false” for the required field
  • Save the file and see the changes

Here i removed the logout link from welcome.aspx

Now my output screen will look like this one.

Cheers,

Kapiljith Rajappan

Identify the Ribbon controls in SharePoint 2010 master pages

When you try for a customized master page there are serious of doubts disturbs your mind. The master page is full of delegate controls and placeholders. So identifying the ribbon control will eat our time.

So let us have a look from the v4.master.

  • Open your site in SharePoint desinger 2010
  • copy the v4.master and rename it as “Ribbon.master”
  • Now find the word “<div id=”s4-ribbonrow”
  • This DIV is responsible for rendering the entire ribbon controls.

Snapshot of Ribbon controls from the masterpage:

If we divide our master page into two portion as header (Ribbon area) and body area. Please identify the same using the below snapshot.

So if i further subdivide and place these controls inside a table as given below …it will be more understandable for you guys.

After making these changes and publishing the master page will give us the output screen like the below snapshot.

Now we will identify the code for SiteActions button and menu.We can find this code snippet within the Ribbon control’s portion.

If we hide this SiteActions in masterpage we will get an ouput like this.

Now we will check the code for Welcome menu(Top Rightmost menu items). We can find its code snippet within the Ribbon control’s portion.

We will hide(comment) these portion using SharePoint Designer 2010.

After making these master page changes the output screen will look like this. So no more Welcome menu for our SharePoint site :-)

Footer for SharePoint 2010 master pages

Let us have a look on how to introduce a footer to SharePoint 2010 master pages. Its pretty simple and will take only few minutes for any developers.

  • Open your site in SharePoint designer 2010
  • Copy the v4.master and paste it and then rename it as “Footer.master”
  • Checkout and edit the “Footer.master”
  • Now search for the text “<SharePoint:DeveloperDashboard runat=”server”/>
  • We need to place the below code snippet before “<SharePoint:DeveloperDashboard runat=”server”/> “

<SharePoint:DeveloperDashboard runat=”server”/>

<!-- START Footer DIV -->
<div id="footer" >
                <!-- START content DIV -->
                <div >
                                <div >Copyright © 2012 KAPILJITH RAJAPPAN. </div>
                                <div ><a href="#">Terms of Use</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#">Privacy Statement</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="#">Sitemap</a></div>
                </div>
                <!-- END content DIV -->
</div>
<!-- END Footer DIV -->

Snapshot from SharePoint 2010 designer:

  • Save your master page, checkin the file, approve and publish the master page.

Snapshot the before the change with v4.master, which is not having any footer :

Snapshot after the change with Footer.master, which is having our custom footer :

So now we will see this footer coming in all pages which uses our custom master page “Footer.master”. But some people dont like the footer appearing in modal dialog windows like the below snapshot.

Snapshot from a modal dialog window:

So to resolve this issue we will utilize one of the default style which is already available in core.css file. Append the “DIV” with id “footer” with the class as “s4-notdlg

<div id="footer"  class="s4-notdlg">

Save, checkin, approve  and publish the major version of Footer.master.

Snapshot after the change:

Hope now you can be the champion for Footers in SharePoint 2010 master pages.

Cheers,

Kapiljith Rajappan

Hide/remove ribbon in SharePoint 2010

Some of you did noticed the SharePoint ribbons behaviour with different access priviledge. For a user having contributor or admin rights…he need the ribbon control to process further actions. But for a user with read or restricted read the ribbon doesn’t serves any purpose.  So the ribbon area will be still visible and the controls will be in a disabled state.

So for making the website a  more GUI friendly by avoiding the ribbon control for those who dont have priviledge use the following snippet.

  • Open your master page in SharePoint Designer
  • Identify the tag which you want to hide. Here in our case “<div id=”s4-ribbonrow”
  • To hide the entrire DIV and its control wrap the entire DIV inside  the below code.

<Sharepoint:SPSecurityTrimmedControl runat=”server” Permissions=”ManageWeb”>

<Here goes your entire code snippet which you want to Hide>

</SharePoint:SPSecurityTrimmedControl>

  • Save the master page and publish it

Look at the various output screen:

GUI for Contributors :

GUI for Reader before change:

GUI for Reader after change:

Cheers,

Kapiljith Rajappan

SharePoint 2010 Social Tags: I Like It and Tags & Notes

You might have noticed the social tags for I Like It  and Tags & Notes. If you wish to provide this delgate control on your custom master page please use one of the following code snippet.

For Large image icons:

<SharePoint:DelegateControl ControlId=”GlobalSiteLink3” Scope=”Farm” runat=”server”/>

For Small image icons: 

<SharePoint:DelegateControl ControlId=”GlobalSiteLink3-mini” Scope=”Farm” runat=”server”/>

Cheers,

Kapiljith Rajappan

JQuery and SharePoint 2010

Is it an easy task for developers to include JQuery on SharePoint 2010 platform?

Yes !!!

Easy steps:

  • Always download the latest version of JQuery from www.jquery.com. Hope you will find the section for download. Take the Minified version which is well optmizedd and compressed for Production rollouts.
  • Now you need to upload the JQuery files either to your website’s shared library or you can place them in “14″ Hive system folder. You can do both scenario if in case JQuery files taking much time to load from website; it can download the same from “14″ Hive folder. So what is 14 folder ? This is the sytem location “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS”.So create a new folder in LAYOUTS as “JQuery” and place the downloaded file.

Similarly we will upload the file into our Style Library in SharePoint. I placed it inside another folder named as “JQuery”

  • Now we have to mention these path in our master page file. Open your master page for editing using SharePoint designer. Check out the file and start adding the following code in the <head></head> section.

<script type=”text/ecmascript” src=”/Style Library/JQuery/jquery-1.7.2.min.js”></script>

<script type=”text/javascript”>

if (typeof jQuery == ‘undefined’)

{   document.write(unescape(“%3Cscript src=’/_LAYOUTS/JQuery/jquery-1.7.2.min.js’ type=’text/javascript’%3E%3C/script%3E”));  }  </script>

Please note that %3E refered as “>”  and %3C as  “<”. Save your master page then publish and apply as master page for your active site. To ensure the scritps are added properly use the IE developer tool (Internet Explorer) or Fire Bug(Mozilla) and check for the added script files which is appearing as expected.

This is my screenshot from IE developer tool.

To learn JQuery some basic knowledge of JavaScript and the document object model (DOM) is required.  Here i am demonstrating with IE developer tool to test the impact of JQuery.

  1. Open your IE developer tool
  2. Select the “Script” tab
  3. From the right side”Console” area append the script code $(document).ready(function() {    $(“a”).click(function() {      alert(“Hello Kapiljith Rajappan testing JQuery!”);    });  });
  4. Click the “Run Script” button
  5. Now click any of the hyperlink in the page which will show the popup alert like the below snapshot .

Cheers,

Kapiljith Rajappan

SharePoint 2010 Themes

The way in themes in SharePoint 2010 arranged is bit different from the previous version of 2007. Now we have themes gallery where we can place theme files.These themes can be applied using the Site themes links from look and feel section of site settings page.

So how to create a custom theme. The best tool would be powerpoint. For editing you can use the tool from Microsoft (Theme Builder)

URL : http://connect.microsoft.com/ThemeBuilder/Downloads/DownloadDetails.aspx?DownloadID=17634

Say if you want to make changes to an existing theme file(Ricasso.thmx).Downlaod it from the themes gallery of Sharepoint and open the file in powerpoint. Save the file as Kapiljith.thmx, make sure the selected type is “Office Theme”

This is to make sure that the XML internal file name should match with the external name.Otherwise it would be like the below sample…

After saving using powerpoint, open the Kapiljith.thmx using “Theme builder” and make necessary changes and upload it back to Themes gallery.Apply the newly created theme from look & feel section of site settings page.

What is this Synchronous and Asynchronous event calls in sharepoint?

In SharePoint we come across many event handlers like …

Microsoft.SharePoint.SPWebEventReceiver(Event happenign at Site Level)
SiteDeleted/SiteDeleting/WebDeleted/WebDeleting/WebMoved/WebMoving

Microsoft.SharePoint.SPListEventReceiver(Event happenign at List Level)
FieldAdded/FieldAdding/FieldDeleted/FieldDeleting/FieldUpdated/FieldUpdating

Microsoft.SharePoint.SPItemEventReceiver(Event happenign at List Item Level)
ItemAdded/ItemAdding/ItemAttachmentAdded/ItemAttachmentAdding/ItemAttachmentDeleted/ItemAttachmentDeleting

So what is the difference in them? Pretty simple to understand.

  • Synchronous will always ends with “ing” eg: ItemAdding/ItemUpdating
  • Asynchronous will always ends with “ed” eg: ItemAdded/ItemUpdated
  • Synchronous event will run at the same time before the event completes its operation. Say we are adding a value, we wish to validate that value. Using synchronous event we can validate it before its get added to the content DB.In other words these event provide us to block the execution of code.
  • Asynchronous event will run only after the items get added.Say if a new item is added to the list and we need to send email notification, if its gender field is male to male@male.com else to female@female.com. The email logic can be integrated to ItemAdded event. 
  • Both methods reduce the performance as it need to execute the custom code from dll. So write the code logic very carefully!

Read more …http://blogs.msdn.com/b/brianwilson/archive/2007/03/05/part-1-event-handlers-everything-you-need-to-know-about-microsoft-office-sharepoint-portal-server-moss-event-handlers.aspx

R.Kapiljiths’s few words on …Bringing navigation menu for WSS/MOSS portals

FYI, there was a query you posted me for enabling the menu items for WSS/MOSS portals. PFB details with which you can accomplish the same  First the menu is driven using the menu control called as , this will utilize the content DB and generate GUI menus. When we drill it to show many sublevel, which required more DB access, performance issue will come into picture. This might be the reason they disabled it purposefully in portal on WSS & MOSS. To enable the functionality you need to make changes to master pages • Default.Master page (/_catalog/masterpage/default.master in the site collection • \12\Template\Global\default.master on the file system. Check the web.config file have the following entry for section • • In master pages check the section • Set the parameter as ShowStartingNode=“True” • Make changes for settings within the < SharePoint.AspMenu / > control as required one. StaticDisplayLevels=”2″ MaximumDynamicDisplayLevels=”1″ Note: Increasing this parameter will create performance issues. Before change After change For more details read the following internet pages. http://sharingpoint.blogspot.com/2007/02/wss-v3-drop-down-menus-in-team-sites.html http://social.msdn.microsoft.com/forums/en-US/sharepointcustomization/thread/6d032478-0b6c-4308-b03f-b04e25e878fe/

rkapiljith’s few words on …IIS Worker Process/Worker Process Group/Web garden

Dependency on installing WSS/MOSS 2007  with windows 2003 server operating system and its web hosting on IIS – 6 is now familiar for us (sharepoint guys). For configuring access priviledge we will go for checking users and group from computer management menu. Here comes our group called as IIS_WPG.Yes the members/accounts of this group have the access priviledge to start and run a worker process.

When we create a web site on our IIS  there will be a associated application pool. These application pool runs its own worker process to operate all request/response on that site. Worker process running in application pool is the hero which help us to differentiate from other website and helps hosting multiple sites on same machine. So when we create another site on same system using IIS Manager we can host the application pool to an existing pool or a new app: pool.If we host it on an existing app: pool two sites request/response will be operated by same worker process.Which is an overhead? At the same time a website can have multiple multiple worker process to operate all request/response of that site.This scenario is called as web garden.

Note: For checking websites/application pool through IIS manager, from windows start window>>Select Run>>Type inetmgr. The tree view display information on  web sites and application pool on that system. But make sure that you already installed IIS 6.0 on your sytem for checking the same. 

Learn more from below URL and share it to others…Best of lucks

http://technet.microsoft.com/en-us/library/bb633256.aspx

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/659f2e2c-a58b-4770-833b-df96cabe569e.mspx?mfr=true

Follow

Get every new post delivered to your Inbox.