Thursday, September 27, 2007

How to brand your SharePoint site with your company's logo

Today someone at work asked me to do a little research on which options there are to add a company logo to a SharePoint 2007 environment. This is quite a basic customization and I thought of a couple of options myself and did some further research on what other people had written. There are (as far as I see it) 4 options to do this:

- Change the logo through the Site Settings (by using the "Title, description, and icon" option). While this is really easy and this doesn't require any coding or designing, the problem with this is that it only changes the logo for the current site, so subsites won't get changed this way.

- You could write a simple command line tool that loops through all your sites and subsites and changes the logo by using SPWeb.SiteLogoUrl. While this is a good way to make sure that every single site gets the new logo, it does require you to run it again when adding new sites.

- A way to make sure that every single site uses the new logo, is to replace the default "titlegrapic.gif" with a new image (of course, backup the default image, you never know...). The image can be found under C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES.

- The last way to replace the site logo is to make a custom master page. In this master page, you replace the placeholder for the site logo with a link to your own logo. Now assign the new master page to your site collection and let it's subsites inherit this master page.
For more info on how to do this one, check out Shane Perran's blogpost.


If you have another suggestion on how to do this, feel free to add it!

Thursday, September 20, 2007

Finally on Google!

Wow, I almost forgot about this blog... It just wouldn't show on google, no matter how I searched for it, so I kind of gave up on it. But I was just trying it again out of curiosity and to my great surprise, it shows up now!! I'll try posting again every once in a while now...

While I'm at it, just something I wanted to share with everyone. You know Disneyland Paris? I've been there for four days last week and I'm not going to give you a whole detailed summary of my trip, but there's one thing I just had to share: VISIT CRUSH's COASTER!! It's a new attraction in the Walt Disney Studios park and it's one of the best roller coasters I've ever been on! No loopings or other fancy twists, but just a fast, thrilling, spinning ride in an awesome scenery... If you ever visit the park, this is a must-do!

Wednesday, April 18, 2007

Creating a document library with a view with grouping in MOSS programmatically

For this project I'm on at the moment, a document library needed to be created programmatically. It needed a view and inside the view, a grouping had to be made.

To do this, I found some info on the various steps on some blogs, msdn, ... but I hardly found anything about grouping. This is why I thought it would be useful to post a code example of the whole thing: creating a document library, creating a view on it and creating a grouping.

The code is fairly simple once you know it, so I won't go any deeper into it. If you've got any questions though, feel free to ask!

WebToAddLibraryTo.AllowUnsafeUpdates = true;

SPListTemplate listTemplate = WebToAddLibraryTo.ListTemplates["Document Library"];

System.Guid guidLib = WebToAddLibraryTo.Lists.Add("Title", "Description", listTemplate);
WebToAddLibraryTo.Update();

SPList docLib = WebToAddLibraryTo.Lists[guidLib];

docLib.EnableVersioning = true;
docLib.EnableMinorVersions = true;
docLib.OnQuickLaunch = true;

docLib.Fields.Add("Field name", SPFieldType.Text, true);
docLib.Fields.Add("Another field name", SPFieldType.Text, false);
docLib.Fields.Add("Date field", SPFieldType.DateTime, false);
StringCollection resultStrings = new StringCollection();
resultStrings.Add("Positive");
resultStrings.Add("Negative");
docLib.Fields.Add("Result", SPFieldType.Choice, false, false, resultStrings);

StringCollection viewFieldCollection = new StringCollection();

viewFieldCollection.Add("DocIcon");
viewFieldCollection.Add("LinkFilename");
viewFieldCollection.Add("Another field name");
viewFieldCollection.Add("Date field");
viewFieldCollection.Add("Result");

string defaultQuery ="<GroupBy Collapse=\"TRUE\" GroupLimit=\"100\">" +
"<FieldRef Name=\"Field name\">" +
"<FieldRef Name=\"ContentType\">" +
"</GroupBy>" +
"<OrderBy>" +
"<FieldRef Name=\"LinkFileName\">" +
"</OrderBy>";


Guid oldViewId = docLib.DefaultView.ID;
docLib.Views.Delete(oldViewId);

SPView newView = docLib.Views.Add("New view", viewFieldCollection, defaultQuery, 100, true, true, SPViewCollection.SPViewType.Html, false);

docLib.DefaultView.Update();

docLib.Update();

Thursday, March 1, 2007

Just something weird while downloading something big...

I just started downloading the trial image of Visual Studio 2005, which is 3.3GB large and in stead of counting up, the download is counting down... It went from 0%, to -1% and right now it's at -7%. Here's a little screen to prove it:


download















Weird... Can't wait for the download being complete at -100%

EDIT: Well, it went way past -100% to something like -200% and then all of a sudden, it went to 393% and now it's counting down from there... I don't have a clue why this is (probably just a miscalculation), but it sure is funny.


download

Monday, February 5, 2007

How to add a BestBet in SharePoint 2007 programmatically

First of all: hi! I'm Tom, software engineer at Dolmen (you know, the company where the infamous jopx works, not by coïncidence the person who I report to...). It took me a while to start blogging, but when I was looking for information on adding BestBets and Keywords programmatically and I couldn't find a thing, it just felt like the right moment to start a blog and "share the wisdom" as they say. Adding Keywords and BestBets is actually not that difficult, you just have to know the right syntax to do so. That's where I come in: here's what I did to make it work:

bool found = false;

Keywords keys = new Keywords(SearchContext.GetContext(SPContext.Current.Site), new Uri(SPContext.Current.Site.Url));

foreach (Keyword key in keys.AllKeywords)
{
if (key.Term.ToLower() == textToCompareTo.ToLower())
{
found = true;
bool foundBet = false;

foreach (BestBet bet in key.BestBets)
{
if (bet.Url == urlToReferTo)
{
foundBet = true;
}
}

if (!foundBet)
{
key.BestBets.Create("Title", "BestBet description", urlToReferTo);
}

break;
}
}
if (!found)
{
keys.AllKeywords.Create(textToCompareTo.ToLower(), DateTime.Now);
}


Now let's explain what this code does...

To start off, we create a boolean that tells us whether the Keyword we want to add a BestBet for is already in the Keywordcollection or not. If it isn't, we'll add it at the end of our code.
The next step is to get all the Keywords of the current Sitecollection you are working on. To do so, we need to create a new Keywordcollection with the context of the current Sitecollection and the url of this Sitecollection.
Once we've found the Keywords, we're going to browse through all the Keywords of the current Sitecollection to check for a match with the Keyword you want to add a BestBet for (in the example I've just used "textToCompareTo" as the string we're looking for). If we find this Keyword in the Keywordcollection, we're going to browse through all the BestBets that have been assigned to this Keyword, to check whether the BestBet we want to add is already part of the BestBetcollection or not. If it is, then our job is done and we don't have to do a thing anymore. If it isn't, we'll add it by creating a new BestBet with a certain title, description and an url we want the BestBet to refer to.

So there you go, not that hard as I first thought it was going to be. If there's any questions or remarks, feel free to leave a comment.