Print Version Email Page Add to Favorites Comments Alert Me Add to My Links

Friday, April 11, 2008

SharePoint : Make a list view that shows only items dated 'This Week'

1. Create a datetime column named Date.

2. Create a calculated column named WeekStart returning type datetime, with the calculation:
=IF(TEXT(WEEKDAY(Date),"ddd")="Mon",Date,IF(TEXT(WEEKDAY(Date-1),"ddd")="Mon ",Date-1,IF(TEXT(WEEKDAY(Date-2),"ddd")="Mon",Date-2,IF(TEXT(WEEKDAY(Date-3) ,"ddd")="Mon",Date-3,IF(TEXT(WEEKDAY(Date-4),"ddd")="Mon",Date-4,IF(TEXT(WEE KDAY(Date-5),"ddd")="Mon",Date-5,Date-6))))))

3. Create a calculated column named WeekEnd returning type datetime, with the calculation:
=IF(TEXT(WEEKDAY(Date),"ddd")="Sun",Date,IF(TEXT(WEEKDAY(Date+1),"ddd")="Sun ",Date+1,IF(TEXT(WEEKDAY(Date+2),"ddd")="Sun",Date+2,IF(TEXT(WEEKDAY(Date+3) ,"ddd")="Sun",Date+3,IF(TEXT(WEEKDAY(Date+4),"ddd")="Sun",Date+4,IF(TEXT(WEE KDAY(Date+5),"ddd")="Sun",Date+5,Date+6))))))

4. Create a view with the following filter:
WeekStart <= [Today] AND WeekEnd >= [Today]

Tuesday, April 08, 2008

Custom Site Theme for SharePoint 2007 (MOSS 2007) and WSS 3.0

Recently I shifted to SharePoint 2007, after working with ASP .Net for more than couple of years.

When it's about developing a web application, the first thing all concentrate is on the UI part of it. Everyone wish to see his/her site with some good UI elements. The SharePoint 2007 gives you more flexibility by introducing the concept of Themes. (Now a days ASP .Net also does support Themes).

The easiest and the fastest way to apply the same look and feel on any SharePoint site is creating a site theme.

A SharePoint site theme basically consists of theme.inf, theme.css, and image files.

  • Theme.inf file simply represents the title of the theme.
  • Theme.css is a stylesheet file that defines colors, header images and layouts of a site
  • Image files can be referenced here to display on the page.

    By creating a custom site theme, you can easily change the style but in fact, writing and editing the stylesheet can be somewhat challenging when you have more than a hundred of elements to deal with.

    Here is a short procedure of creating a custom site theme named "Ghost":

    1. Copy any theme folder in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES" folder and paste with its name replaced with "Ghost". In this example, copy GRANITE folder.

    2. In Ghost folder, rename GRANITE.INF file to GHOST.INF in upper case.

    3. Open GHOST.INF file with notepad.

    4. Change the value of title under [Info] to Ghost.

    5. Replace every word, Granite, under [titles] with Ghost.

    6. Open "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\SPTHEMES.XML" file with notepad.

    7. Add the following lines under tag:

    Ghost
    Ghost
    Ghost theme.
    images/thghost.gif
    images/thghost.gif

    Notice that preview and thumbnail paths are images/thghost.gif. By default, MOSS 2007 and WSS 3.0 will not have such image files.

    8. In order to display thumbnail and preview correctly, you will need to capture the screen and save the file in "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES" folder with thghost.gif name. You can change the .gif file name if you change the thumbnail and preview file names in tag.

    9. Do an iisreset for the server to recognize the new theme.

    Pretty simple procedure. Now you are ready to test your new theme. In Site Settings, you can now choose Ghost theme; however, the theme will not differ from Granite theme. Now, it is time for you to play with theme.css file!

Monday, May 08, 2006

Add Yahoo! Messenger Status on Your Website

If you ever wonder how to show your Yahoo! Messenger online status in your web page you’ll find an answer here. Yahoo! provides a URL which allows getting this information in graphic or text mode.

Note:
Before you go, please be sure that your online status is not hidden in your account settings.

Here is the URL template and the parameters that you have to supply when calling it.

http://opi.yahoo.com/online?u={your yahoo id}&m={gt}&t={123}

A bit description of the parameters:
  • u - Your Yahoo! ID
  • m - Status mode, either graphic (g) or text (t)
  • t - Type of graphic or text to be displayed

    An example is shown below:
    <img src="http://opi.yahoo.com/online?u=nanddeepnachan&m=g&t=0" />
    <img src="http://opi.yahoo.com/online?u=nanddeepnachan&m=g&t=1" />
    <img src="http://opi.yahoo.com/online?u=nanddeepnachan&m=g&t=2" />

    And here goes the result:


  • Thursday, April 20, 2006

    Change MSN Messenger Status Programmetically

    C# Application to change MSN Messenger Status.

    MSN Messenger 7.0 introduced the notion of a personal message, a small message that's not poisening your nickname if you want to share something with your contacts. Quite a lot of people are using this nowadays to put their favorite quote over there or just to share a random thought. Beside of the manual entry of a personal message, such a message can be automatically generated as well by an external application.

    This way, it's possible to show your friends "what you're listening to". Basically, a music player such as Windows Media Player does some IPC (Inter-Process Communication) to MSN Messager using the Win32 API every time the song which is currently playing changes. The nice thing is that you can write your own plug-in using some relatively simple C#:

    1. Create a Windows Forms application and open the source code view for the Form1.cs form.

    2. Add the namespace:
    using System.Runtime.InteropServices;

    3. In the class definition, put two DllImports as follows:

    [DllImport("user32", EntryPoint="SendMessageA")]private static extern int SendMessage(int Hwnd, int wMsg, int wParam, int lParam);

    [DllImport("user32", EntryPoint="FindWindowExA")]private static extern int FindWindowEx(int hWnd1, int hWnd2, string lpsz1, string lpsz2);

    4. Import the WM_COPYDATA constant for the Win32 API calls:
    private const short WM_COPYDATA = 74;

    5. Declare a struct for the IPCs we're going to perform:
    public struct COPYDATASTRUCT
    {
    public int dwData;
    public int cbData;
    public int lpData;
    }
    public COPYDATASTRUCT data;

    6. Function that makes interop to MSN Messenger
    public int VarPtr(object e)
    {
    GCHandle GC = GCHandle.Alloc(e, GCHandleType.Pinned);
    int gc = GC.AddrOfPinnedObject().ToInt32();
    GC.Free();
    return gc;
    }

    Now the plumbing is done, we can start implementing the IPC-method to MSN. The only thing you need to know is the identification string of the MSN Messager 7 application, which is "MsnMsgrUIManager".

    The code for the method is displayed below:
    private void SendMSNMessage(bool enable, string category, string message)
    {
    string buffer = "file://0/" + category + "file://0/" + (enable ? "1" : "0") + "file://0{0}//0" + message + "file://0//0//0//0/0";
    int handle = 0;
    data.dwData = 0x0547;
    data.lpData = VarPtr(buffer);
    data.cbData = buffer.Length * 2;
    handle = FindWindowEx(0, handle, "MsnMsgrUIManager", null);

    if (handle > 0)
    {
    SendMessage(handle, WM_COPYDATA, 0, VarPtr(data));
    }
    }

    Basically, this method takes three parameters.
    The first indicated whether to display a message or not.
    The second one contains a category which can be "Office", "Games" or "Music".
    The last parameter takes the message itself.

    Assuming MSN Messenger 7.0 is running on your machine (in the current user session), a call to:
    SendMSNMessage(true, "Office", "Hello World"); would put "(Office logo) Hello World" behind your nickname in MSN. By calling: SendMSNMessage(false, "Office", ""); the message will be gone and the old personal message of MSN will be restored. Note that for this to work, you should put on the feature "What I'm listening to" in MSN 7.0. It's this feature which listens to incoming IPC messages in order to display them.

    World Clock