Category Archives: SharePoint Customization

Lovely 12 Hive :)

A couple of hours ago, while surfing the MSDN Forums and I experienced a very interesting Question, well, let’s me share with you here the Question and my answer.

Q : We are creating a custom field type in a multilingual publishing site, we need to use the DisplayPattern to render the field value plus other Data that is language specific? Any ideas ?

A : Again , “The 12 hive is our teacher”.You know the little “New!” Icon that is displayed beside an Item when it’s newly created ?I’ve once created an Arabic/English site and I found out that the image is rendered in Arabic in the Arabic context and in English in the English Context which is great. Then you can definetly do that too either by Code or by CAML.
Let’s see if we can achieve that by means of CAML.
Open the 12 hive, Templates, Featues and open the folder of the fields feature, then open fieldswss.xml.
check the field titled “LinkTitleNoMenu” and let’s have a look at its display pattern.I’ve copied a part of it here, what I care about is the undlerlined part of the CAML below ..

<DisplayPattern>
<IfEqual>
<Expr1><LookupColumn Name=”FSObjType”/></Expr1>
<Expr2>1</Expr2>
<Then><Field Name=”LinkFilenameNoMenu”/></Then>
<Else>
<HTML><![CDATA[<a onfocus=”OnLink(this)” href=”]]></HTML><URL/>
<HTML><![CDATA[” ONCLICK=”GoToLink(this);return false;” target=”_self”>]]>
</HTML>
<Column HTMLEncode=’TRUE’ Name=”Title” Default=’$Resources:core,NoTitle;’>
</Column>
<HTML><![CDATA[</a>]]></HTML>
<IfNew>
<HTML><![CDATA[<IMG SRC=”/_layouts/[%=System.Threading.Thread.CurrentThread.CurrentUICulture.LCID%]/images/new.gif” alt=”]]></HTML>
<HTML>$Resources:core,new_gif_alttext</HTML>
<HTML><![CDATA[“>]]></HTML>
</IfNew>
</Else>
</IfEqual>
</DisplayPattern>

Got it ?You can write server-side code inside your display pattern :0 TERRIFIC
By the way I just discovered that when trying to answer your question but a little humble piece of advice to you is ” Love your 12 hive, Check out the OOB features, 12 Hive can really teach us a lot of cool stuff related to the UX

That was my answer and I’m waiting for him/her to mark it as answered LOL!
see you

Advertisement

SharePoint Customization Tricks – Part 3

This multipart series of articles is intended to help you getting ramped up with SharePoint Customization. It’s about modifying the default SharePoint user experience, list forms customization, branding, skinning SharePoint portals, etc.

In Part 1, I introduced a generic function that you can use to hide the list view toolbar menu items (e.g. New Item, Upload, Edit in Grid view, etc.). In Part 2, I showed you how to remove items from the list form toolbar. If you haven’t read both posts yet, I would encourage you do to that first .

After posting the previous articles, I received a lot of e-mails from SharePointers asking how to rename the items in the list form toolbar. That’s why I decided to write Part 3 in the series. After I finished writing the article and taking some snapshots, another SharePointer asked me on MSDN Forums if it’s possible to remove the Text while retaining the images, for instance, removing “Delete Item” while retaining the (X) rendered beside it. Today I’ll show you to do both tasks by JavaScript.

Trick #4: Renaming List Form Toolbar Items!

Sometimes, you need to rename some items in the toolbar rendered at the top of DispForm.aspx to match the List Name. For instance, you have a custom list named “Programs” that stores the courses offered by a university. It would be better to have “New Program” rather than the default “New Item” and “Edit Program” rather than “Edit Item”. Sometimes, you just need to totally delete the text and just leave the images with a tooltip that explains the action performed on clicking them.

Before

6

 

After

7

This function can be used to achieve both tasks, just call the function passing the old and new names of the item. For instance if you need to rename “Add Item” to “Add Program”, use renameFormMenuItems(“Add Item”,”Add Program”);. In case you need to remove the text and leave the image, call the function passing an empty string as the new name as follows: renameFormMenuItems(“Delete Item”,””);.

Download Function from here

Kindly note that the function is case sensitive, so “New Item” will work while “nEw iTeM” is not gonna work.

Nice and easy, isn’t it?

Now a question is imposing itself, how can we use this function? The answer is the content editor web part; please refer to trick #3 in the previous article for more information.

What about hiding the toolbar altogether?

8

There are a lot of solutions that imply unghosting the page using SharePoint Designer, but I don’t prefer those solutions! Again, let’s perform this task using JavaScript. I’ve included two functions in the zip file, one for renaming the toolbar items and the other for hiding the toolbar altogether! Waiting for your feedback.

SharePoint Customization Tricks – Part 4

This multipart series of articles is intended to help you getting ramped up with SharePoint Customization. It’s about modifying the default SharePoint user experience, list forms customization, branding, skinning SharePoint portals, etc.

In Part 1, I introduced a generic function that you can use to hide the list view toolbar menu items (e.g. New Item, Upload, Edit in Grid view, etc.). In Part 2, I showed you how to remove items from the list form toolbar. If you haven’t read both posts yet, I would encourage you do to that first .

After posting the previous articles, I received a lot of e-mails from SharePointers asking how to rename the items in the list form toolbar. That’s why I decided to write Part 3 in the series. After I finished writing the article and taking some snapshots, another SharePointer asked me on MSDN Forums if it’s possible to remove the Text while retaining the images, for instance, removing “Delete Item” while retaining the (X) rendered beside it. Today I’ll show you to do both tasks by JavaScript.

Trick #4: Renaming List Form Toolbar Items!

Sometimes, you need to rename some items in the toolbar rendered at the top of DispForm.aspx to match the List Name. For instance, you have a custom list named “Programs” that stores the courses offered by a university. It would be better to have “New Program” rather than the default “New Item” and “Edit Program” rather than “Edit Item”. Sometimes, you just need to totally delete the text and just leave the images with a tooltip that explains the action performed on clicking them.

Before

6

After

7

This function can be used to achieve both tasks, just call the function passing the old and new names of the item. For instance if you need to rename “Add Item” to “Add Program”, use renameFormMenuItems(“Add Item”,”Add Program”);. In case you need to remove the text and leave the image, call the function passing an empty string as the new name as follows: renameFormMenuItems(“Delete Item”,””);.

Download Function from here

Kindly note that the function is case sensitive, so “New Item” will work while “nEw iTeM” is not gonna work.

Nice and easy, isn’t it?

Now a question is imposing itself, how can we use this function? The answer is the content editor web part; please refer to trick #3 in the previous article for more information.

What about hiding the toolbar altogether?

8

There are a lot of solutions that imply unghosting the page using SharePoint Designer, but I don’t prefer those solutions! Again, let’s perform this task using JavaScript. I’ve included two functions in the zip file, one for renaming the toolbar items and the other for hiding the toolbar altogether! Waiting for your feedback.

SharePoint Customization Tricks – Part 2

Introduction
This multipart series of articles is intended to help you getting ramped up with SharePoint Customization. It’s about modifying the default SharePoint user experience, list forms customization, branding, skinning SharePoint portals, etc. In Part 1, We introduced a generic function that can be used to hide the list view toolbar menu items (e.g. New Item, Upload, Edit in Grid view, etc). If you haven’t read it yet, I would encourage you do to that first. Today I’ll show you another two tricks for customizing the list form toolbar.

Trick #2 : Hiding List Form Toolbar Menu Items!

9

Sometimes, you need to remove some items from the toolbar that appears at the top of DispForm.aspx. Unfortunately, the “HideCustomAction” feature can merely hide the items which have been rendered through the “Custom Action” feature framework such as Site Actions and Site setting so let’s take the same approach we took in Part 1 which is delving back into the world of JavaScript which I really find very handy when it comes to SharePoint customization.
The following function can be used to hide any toolbar item in dispform.aspx. Just call the function passing the names of the items comma separated (e.g. New Items, Alert Me, etc.). The function removes the items and of course the images rendered beside them (if found).
Download hideFormMenuItems.zip – 755 B , Trick #3 will deal with where and how you can add the function to your list form.

Trick #3 : Adding JavaScript Through CEWP!

The content editor web part gives you the ability to add any valid HTML on the web part page you place it and this surely includes ”

10

Where the heck is Edit Page Menu Item?!! Just like the old version, it’s not available, I’m still not sure why they did that!
Trick #3 : Just append “&ToolPaneView=2” to the URL and you will have DispForm.aspx in the Edit Mode in your Browser.

12

Add a content editor web part just below the web part that renders the list form and insert the JavaScript of Trick #2 as shown in the figure below. (It’s preferable to mark the content editor web part as hidden).

13

14

Exit the edit mode…

16

remendous, we managed to hide “New Item” and “Alert Me”.What about renaming “Edit Item” to “Edit Program” and Removing “Delete Item” but leaving the small image (x)? That is what I’m going to cover in trick#4 in the next part!

SharePoint Customization Tricks

This multipart series of articles is intended to help you getting ramped up with SharePoint Customization. It’s about modifying the default SharePoint user experience, list forms customization, branding, skinning SharePoint portals, etc. When I looked around the “SharePoint Landscape”, I noticed the lack of documented experiences in the SharePoint customization area and thus this multipart series of articles was born.

Prerequisites
First you need to have prerequisite skills in .NET Development and in particular ASP.NET Development, you should also have basic understanding of JavaScript, SharePoint and how to use it from the User Interface and of course you should have some experience in using the SharePoint customization tool (SharePoint Designer).

Trick #1 : Hiding List View Toolbar Menu Items!

17

I’ve gone through SharePoint projects on different scales; a common requirement among most of these projects is hiding some menu items that are implemented by default within the framework of SharePoint. The obvious choice from the SDK is HideCustomAction ! After digging through theweb, I found out the following:

  • The “HideCustomAction” feature can merely hide the items which have been rendered through the “CustomAction” feature framework such as Site Actions and Site setting…. etc.
  • ECB (Context Menu) items are rendered by JavaScript from Core.js file so we can’t hide them via “HideCustomAction” feature. However, you can add a new menu item in the ECB menu through “CustomAction” feature and hide it again through The “HideCustomAction” feature. In other words,” HideCustomAction” feature can be used to hide the ECB menu items that you created via CustomAction but can’t be used to hide the out of the box menu items.
  • The ListViewWebPart menu items ( New menu, Upload menu, Actions menu,… etc ) are rendered through a class library as a web control from the Microsoft.SharePoint.dll so they can’t be hidden through The “HideCustomAction” feature.

Hmm, I thought of delving back into the world of JavaScript and I came up with some generic functions that can be used to hide any menu item in SharePoint and I decided to share them with the community.

You can download hideListViewToolbarItems fumction from :

https://www.codeproject.com/KB/sharepoint/sharepoint-customization.aspx

You can use this function to hide any menu items rendered in the ListViewWebPart toolbar which is used in the list view pages, just call the function and pass the menu item names ( comma separated ) as they appear in the toolbar ignoring the case. Only one exception to that when you need to hide “Create View” which appears twice one in “List Settings” and the other one in the view selector, in order to resolve this conflict just call the function as follows : hideListViewToolbarItems(“settings:create view”) or hideListViewToolbarItems(“view:create view”).

SharePoint Delegate Controls Unclouded

Introduction

Over the past few months I have been working on branding the SharePoint portal of one of the largest international companies. This was really interesting especially that this was the first branding experience for me. While I was looking at the OOB master page ( default.master ), I noticed there is a control called “delegate control” in the head element right below the “PlaceHolderAdditionalPageHead”. After googling and investigating, I can say that Delegate Control is one of the most important features of SharePoint 2007 when it comes to branding and customization.

History

Back to 2003, When Microsoft released Microsoft SharePoint portal server 2003, it was cool but what extremely annoyed the developers then is the non-extensibility of the product and the difficulty of customization. Now, MOSS 2007 offers many extension points to alter sites even after they have been provisioned. The introduction of SharePoint features has opened up an entire world to modifying master pages, page layouts and the pages themselves. Further, SharePoint introduced Delegate Controls that allow for more granular control over parts of the page.

Why are they cool and handy ?

On every SharePoint deployment I have ever participated in, it has been requested that the Search Box be modified. In previous SharePoint versions, this involved either unghosting and customization and/or creating a whole new site definition. NOW, Thanks to Delegate Controls, you can take any control and place them on a SharePoint page such that they substitute the existing control at whatever scope you desire and yet require no extra coding or redeployment of the pages themselves. They work hand-in-hand with the newly introduced Features Framework to dynamically load a control at runtime based on a key value and sequence number

Enough Theory, How do they work ?

The default.master file that the global site definition deploys contains some Delegate Controls with the following Id values :

  • AdditionalPageHead
  • GlobalSiteLink0
  • SmallSearchInputBox
  • PublishingConsole

For instance, SmallSearchBox displays a search area and the DelegateControl Definition in default.master is :

<SharePoint:DelegateControl runat=”server” ControlId=” SmallSearchBox”>

All versions of SharePoint contain a feature called ContentLightUp that includes a Control element that specifies a control for the DelegateControl with the SmallSearchArea ControlId value. The element looks like this :

<Control Id=”SmallSearchInputBox” Sequence=”100” ControlSrc=”~/_controltempaltes/searcharea.ascx” />

The enterprise version of MOSS contains a feature named OSearchEnhancedFeature that substitutes the searcharea.ascx user control with SearchBoxEx web control that sends the user to the more advanced search page in MOSS.

<Control Id=”SmallSearchInputBox” Sequence=”50″ ControlClass=”Microsoft.SharePoint.Portal.WebControls.SearchBoxEx” ControlAssembly=”Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral,PublicKeyToken=71e9bce111e9429c”>

When SharePoint selects the control to replace the delegate control, it looks through the list of activated controls and selects the best control and the best control is defined as the one that has the lowest sequence number. Because the control element in OSearchEnhancedFeature has a lower sequence number, the control it defines is loaded instead of the one determined in ContentLightup and this occurs without modifying default.master .

There are other DelegateControls, like AdditionalPageHead, that do not have visual elements but instead provide the ability to insert additional HTML at runtime.

For example, I once created a web control called SearchEngineOptimizer that emited META tags ( Meta Tags are html tags that appear in the head of html pages) for search engine optimization and created a feature to load that web control!

Well, there is a couple of tips and recommendations that I want to highlight :

  • By using a feature scoped at web, you can use different search boxes for different areas in your site collection with no extra code.
  • You can load user or server controls, if you are specifying a user control, use URL attribute, if you want to load a server control use ControlClass and ControlAssembly attributes.
  • By adding AllowMultiple=true in to the delegate control declaration, you can make it load more than one user/server controls. ( for instance AdditionalPageHead delegate control is set to allow multiple controls by default).
  • When designing your page, create delegate controls for functionality that might change over time.
  • Keep tack of the sequence and don’t use too low numbers. You don’t want to have trouble overriding the feature in the future.

Summary

Delegate Controls are important design options for creating solutions that can mixed and matched with other options. The ability to light up functionality for one site and not another can be a very important tool in the SharePoint developer’s toolbox.

Master Pages Tokens

Hi guys, It’s a little post, but I thought it would be useful for beginners to SharePoint branding.
“Master Pages” is an essesntial topic when it comes to SharePoint Branding as they provide consistency by providing a common layout, content, look and feel across the pages that use them.

Note the reference to the token ~masterurl/default.master in the first line in any sharepoint content page.

When you use the attribut MasterPageFile into your page header, you can give the relative url of the master page you want.
There also some token to give you more options :
Dynamic token :
“~masterurl/default.master”>>> This token references a master page from a content page by using the MasterPageFile attribute together with the value of the MasterUrl property. And this resolves by default to /_catalogs/masterpage/default.master but you can change the MasterUrl property using SharePoint designer or using Master Page page under Site Settings via the browser .
“~masterurl/custom.master”>>> This token references a master page from a content page by using the MasterPageFile attribute with the value of the CustomMasterUrl property . Also it resolves to /_catalogs/masterpage/default.master by default.

MSDN Note : If you subsequently need to delete the default.master file, you must set both of those properties to a different value.
Static token :
“~site/x”>>> This token link to the current site-relative path
“~sitecollection/x”>>> This token link to the current site collection-relative path

For example, if your content page is located at http://myPortal/subsite1/subsite2/default.aspx and you use the token “~sitecollection/mypage.master”, your content page would use the master page athttp://myPortal/mypage.master. If you use the token “~site/mypage.master”, the content page would use the master page located at http://myPortal/subsite1/subsite2/mypage.master .

Tip : It’s also possible to control the selection of Master Pages at run time with .NET code using the page’s OnPreInit method or by using an HttpModule. ( will be discussed in later posts ) .