Sipping cocktails in Queensland

March 30, 2007

For those that know me, you will know that I have a tendency of collecting all sorts of things, but my main collection fetish is all things M&M related. I have in my collection some 40 M&M chocolate dispensers, some are classic ones from the 80’s and some are newer ones I got for Easter. I also collect M&M folders, pens, cups and stuffed toys. My favourite item is a mini M&M jukebox dispenser that plays the Lambada when it dispenses. For Christmas my mother in law got a hold of my four Star Wars M&M post cards and had them block mounted (very cool present).

So I was reading Chris’ blog and found that he had posted about a cool website that lets you design your own M&M character (www.becomeanmm.com). So I cranked up the site a created a character that is going to sum up my holiday in Queensland…so off I go to the warm sunny beaches to sip cocktails…see you when I get back.

My M&M Character


Away in the Sun with my family

March 29, 2007

I am heading north to sunning Queensland on Saturday morning to spend some well deserved holiday time with my lovely wife and two wonderful children. I am not taking my laptop with me and therefore blogging will be just a little bit difficult. So my blog will be quiet for the next two weeks.

We are spending 5 or so days on the Gold Coast and will be doing Dreamworld, White Water World and lots of Direct Factory shopping at Habourtown Shopping Centre, before we head further north to Noosa where we will spend another 5 or so days.

I will speak to you all again and post some holiday snaps when I get back.


Change the default page when site is created

March 29, 2007

When you create a new publishing site in MOSS it automatically gets a default page created using the WelcomeLinks.aspx page layout. How can you change this behavior and have it automatically create a page based on a content type and page layout of your choice? Read on to find out how.

The Publishing template (as do all templates) have an ONET.XML file. In this file there is a modules section (as below), this defines the PublishingPageLayout and ContentType to be used when a site is created.


<Modules>
    <Module Name="Home" Url="$Resources:cmscore,List_Pages_UrlName;" Path="">
        <File Url="default.aspx" Type="GhostableInLibrary" Level="Draft" >
            <Property Name="Title" Value="$Resources:cmscore,IPPT_HomeWelcomePage_Title;" />
            <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/WelcomeLinks.aspx, ~SiteCollection/_catalogs/masterpage/WelcomeLinks.aspx" />
            <Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;" />
        </File>
    </Module>
</Modules>

This could be changed to specify any default content type and page layout. The following shows how you might change it to a content type called MyContentType and a default page layout called MyPageLayout.aspx;


<Modules>
    <Module Name="Home" Url="$Resources:cmscore,List_Pages_UrlName;" Path="">
        <File Url="default.aspx" Type="GhostableInLibrary" Level="Draft" >
            <Property Name="Title" Value="$Resources:cmscore,IPPT_HomeWelcomePage_Title;" />
            <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx, ~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx" />
            <Property Name="ContentType" Value="MyContentType" />
            <Property Name="PublishingAssociatedContentType" Value=";#MyContentType;#0x010100C568…3A09F31E1FBA;#" />
        </File>
    </Module>
</Modules>

Note: The big number 0x010100C568…3A09F31E1FBA is obtained from the Url of the Content Type.


Using ASP.Net user controls ASCX in MOSS/WSSv3

March 28, 2007

Chris Johnson has posted a great article on using ASP.Net ASCX user controls in MOSS/WSSv3. I have been recently creating custom controls in Visual Studio (i.e. Control Classes not ASCX). To use these I add the controls to the GAC and then add an entry to the web.config to make it a safe control. The benefit of the ASCX model is that you can develop the user control in a more visual manner.

The ASCX controls can be used in MOSS/WSSv3 via the following method:

1. Create a Directory called “usercontrols” in the root of your sharepoint web site on the file system E.g. C:\Inetpub\wwwroot\wss\VirtualDirectories\moss.litwareinc.com80\UserControls

2. Open IIS manager and in the root of your SharePoint site create a VirtualDirectory called “_controls” and point it to that newly created directory.

3. Put your user control in that newly created directory on the filesystem

4. Open the web.config file and add the following:

<SafeControl src="~/_controls/*" mce_src="~/_controls/*" IncludeSubFolders="True" Safe="True" AllowRemoteDesigner="True" /">

5. In your ASPX page add the following:

<%@ Register src="~/_controls/SomeControl.ascx" mce_src="~/_controls/SomeControl.ascx" TagName="somecontrol" TagPrefix="uc2" %">

And…

<uc2:somecontrol id="mycontrol1" runat="server"></uc2:somecontrol>

6. Run your ASPX page and your control should render correctly.


MOSS AdRotator Control

March 27, 2007

I recently had a client who wanted an AdRotator on their MOSS Internet site. The client wanted to randomly choose an image from a nominated Image Library and display it on the home page. Unfortunately there is no Moss AdRotator control out-of-the-box. So I went back to my MCMS roots and adapted the MCMS AdRotator found on MCMS faq.com.

Take the MCMS AdRotator, rename it to MossAdRotator, and modify the OnAdCreated to obtain a random SPListItem from the nominated SPList (adsLibraryName) of the Current Web. Note: The code below assumes that the Image Library is located in the current web, but that could be adapted.

protected override void OnAdCreated(AdCreatedEventArgs e)
{
    try
    {
        SPWeb web = SPContext.Current.Web;
        SPList list = web.Lists[adsLibraryName];
 
        if (list != null)
        {
            int resourceIndex = Randomiser(list.ItemCount);
            SPListItem li = list.Items[resourceIndex];
 
            string webUrl = web.ServerRelativeUrl;
            if (webUrl != "/")
            {
                webUrl = webUrl + "/";
            }
 
            e.ImageUrl = web.Url + "/" + li.Url;
            e.AlternateText = li.DisplayName;
        }
        else
        {
            throw new Exception(
              "The Picture Library '" +
              adsLibraryName +
              "' could not be found.");
        }
    }
    catch (Exception ex)
    {
        if (displayErrors)
        {
            e.AlternateText = ex.Message;
        }
        else
        {
            this.Visible = false;
        }
    }
}

Update: Quite a few people have asked me for a downable copy of the MossAdRotator control, so I have created a C# class file that you can download.


Most recent document sidebar gadget

March 26, 2007

I was looking through the Vista sidebar gadgets on live gallery and found this excellent gadget “Microsoft Office 2007 Recently Used Documents“.

“Quick and easy access to your most recently used Microsoft Office Word 2007, Excel 2007, and PowerPoint 2007 documents. This gadget lets you easily open, pin, or unpin the most recent items from your Word, Excel, and PowerPoint MRU. Requires Office 2007.”

I am using it now and have found it to be very useful, so I can recommend checking it out. Hopefully the list of files, which currently only support Word, Excel and PowerPoint will be expanded in the future.

Image of Microsoft Office 2007 Recently Used Documents Vista Sidebar Gadget


New Groove developer portal on MSDN

March 26, 2007

Microsoft Groove

Just read that the new Groove developer portal on MSDN has gone live.

This is a home for developers who want to learn more about Groove and how to develop solutions on the Groove platform. The site also links to relevant content on TechNet and Office Online, providing easy access to those materials.

This enables developers new to Groove to build a solid foundation of knowledge before taking Groove deployments to the next level by building a custom solution.

MOSSIG Meeting on Wednesday evening 28th March 2007

Don’t forget that Marc Dimmick will be presenting part 2 of his Microsoft Office Groove 2007 presentation at the MOSSIG meeting on Wednesday evening, this month from a business scenario perspective. If you are wondering what the value of Groove can be for your business this is a must see presentation.