Expose the Web Part Title in the XSL of your CQWP

The last couple of days, I have been busy with customizing the OOTB Content by Query Web Part and Summary Links Web Part from SharePoint 2010. I wanted to get rid of the default look and chrome and present my data in a nice box with rounded corners and a title with matches the rest of my styles.
After 2 days of trying, I can say… the result is too my liking. :-)

The first box is a Summary Links Web Part and the box below it, is a Content by Query Web Part.
To get rid of the default chrome, I simply set it to None in the Web Part properties.

 

 

 
Continue reading

VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

Create a cache profile in SharePoint using PowerShell

I have been looking for a way to create a new cache profile in SharePoint using Powershell. This profile can be used in the Page Output cache.
I noticed that cache profiles are stored in a list called “Cache Profiles” and implement the “Page Output Cache” content type.

So, creating a new profile shouldn’t be that difficult.

$site = Get-SPSite $rootURL
$web = Get-SPWeb $rootURL
$list = $web.Lists["Cache Profiles"]
$ctCacheProfile = $list.ContentTypes["Page Output Cache"]
$profile = $list.Items.Add()
$profile["ContentTypeId"] = $ctCacheProfile.Id
$profile.Update()

$profile["Title"] = "My Custom Cache Profile"
$profile["Display Name"] = "My Custom Cache Profile"
$profile["Description"] = "My Custom Cache Profile"
$profile["Perform ACL Check"] = $true
$profile["Enabled"] = $true
$profile["Duration"] = "180"
$profile["Check for Changes"] = $false
$profile["Vary by Custom Parameter"] = "Browser"
$profile["Vary by HTTP Header"] = ""
$profile["Vary by Query String Parameters"] = ""
$profile["Vary by User Rights"] = $true
$profile["Cacheability"] = "ServerAndPrivate"
$profile["Safe for Authenticated Use"] = $true
$profile["Allow writers to view cached content"] = $false
$profile.Update()

To add the profile to your Page Output Cache and enable the cache, you can use the following code:

$cacheSettings = New-Object Microsoft.SharePoint.Publishing.SiteCacheSettingsWriter($rootURL)
$cacheSettings.EnableCache = $true
$cacheSettings.SetAuthenticatedPageCacheProfileId($site, $profile.ID)
$cacheSettings.Update()
VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

Create Content Organizer Rules using PowerShell

I just wanted to share a way to create Content Organizer rules in SharePoint 2010 using PowerShell. I was looking for a way to implement those rules using a script.
The first thing I did was create a rule using the UI and then fire up SharePoint Manager to have a look at it and how it has been built up.
So, those rules are stored in a hidden list called “Content Organizer Rules”. Creating a new listitem in that list however is not that straightforward. I did found out that a rule is actually an instance of the Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule class. The link above contains an example on how to create a rule programmatically.
If it’s possible in C#, then it must be possible in PowerShell.
The script below is what I came up with and it works like a charm:

[Microsoft.SharePoint.SPSite]$site = Get-SPSite http://www.mycompany.com
[Microsoft.SharePoint.SPWeb]$web = Get-SPWeb http://www.mycompany.com
[Microsoft.SharePoint.SPContentType]$ct = $site.RootWeb.ContentTypes["MyContentType"]
[Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule]$rule = New-Object Microsoft.Office.RecordsManagement.RecordsRepository.EcmDocumentRouterRule($web)

$rule.Aliases = $ct.Name
$rule.ConditionsString = "<conditions></conditions>"
$rule.CustomRouter = ""
$rule.Name = $ct.Name
$rule.Description = "Routes '" + $ct.Name + "' documents to it's own library"
$rule.ContentTypeString = $ct.Name
$rule.RouteToExternalLocation = $false
$rule.Priority = "5"
$rule.TargetPath = $web.Lists["MyLibrary"].RootFolder.ServerRelativeUrl
$rule.Enabled = $true
$rule.Update()

The thing to remember is the ConditionsString. If you don’t specify a specific condition, you can’t just leave it empty. You have to include the tags of the Conditions element. If you do need to specify additional conditions, then the easiest way to construct this string is to create the rule in the UI, inspect the Xml string of the rule with SharePoint Manager and look at the “ows_RoutingConditions” argument, which contains the condition.

VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

Limit list of available web templates in your custom site definition

SharePoint 2010 allows you to create custom web templates or site definitions.
Using the UI, you can limit the available web templates which users are allowed to use if they want to create a new site. But what if you want to do this automatically and you have your own custom site definition or web template and you want limit this list of templates to a number of custom definitions?
This is possible.
You can specify the allowed templates in your custom onet.xml.
In this file, you have a Publishing feature with ID {22A9EF51-737B-4FF2-9346-694633FE4416} where you can add a property with the name “AvailableWebTemplates”. The value for this property is a list of web templates.
The format of this list is as follows:
”*-{FeatureID}#WebTemplateName1;*-{FeatureID}#WebTemplateName1;”

The FeatureID is the GUID of the feature which contains the definitions for the web templates.
The WebTemplateName can be found in the elements.xml of the web template.

VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

AvailablePageLayouts property value has to be one a single line

Today, I was deploying a custom web template in SharePoint 2010 in which I had specified that only 9 custom page layouts were allowed. I did this by adding a property to the Publishing feature (id 22A9EF51-737B-4ff2-9346-694633FE4416) in my custom onet.xml file called AvailablePageLayouts where you specify the location and the name of the allowed page layouts.
The format of the string with the list of layouts you specify as the value for that property has to be specific:

  • the location of the page layout has to be a relative URL
  • they have to separated by a colon (:)
<property Key="AvailablePageLayouts"
          Value="~SiteCollection/_catalogs/masterpage/ArticleLeft.aspx:
                 ~SiteCollection/_catalogs/masterpage/ArticleLinks.aspx:
                 ~SiteCollection/_catalogs/masterpage/ArticleRight.aspx"/>

After I deployed the feature I created a new site from my custom template and all of a sudden I got an error:

All Page layout urls inside the string have to be server relative
The error message furthermore mentioned more information on which page layouts were affected.

When I looked at the list of page layouts I added to this property, they all had relative urls.
Since the 1st layout was not mentioned in the error, something started to go wrong with the second one. I placed each page layout on a new line because that was so much easier than a single line and this was the problem. So, I put everything on a single line and for sure… this solved the error. My site was created successfully and only the 9 specified page layouts were available.

Update (4/12/2011): Someone commented on this post that you can actually split the page layouts over multiple lines for readability. You just need to start each line with the colon. And he’s right. The next does work:

<property Key="AvailablePageLayouts"
          Value="~SiteCollection/_catalogs/masterpage/ArticleLeft.aspx
                :~SiteCollection/_catalogs/masterpage/ArticleLinks.aspx
                :~SiteCollection/_catalogs/masterpage/ArticleRight.aspx"/>
VN:F [1.9.14_1148]
Rating: +2 (from 2 votes)

“s4-notdlg” not doing what it should be doing

Today, I was playing around in SharePoint 2010 and I was setting up a FAQ where you show the questions using a CQWP and open the details in a SharePoint popup dialog. Works great but the problem was that I was trying out a custom masterpage and the dialog showed the complete masterpage with the header, left navigation and so on… not what you want. I switched to a OOTB masterpage and it worked. So it had to be something in my custom masterpage.

Then it hit me, you need to add the s4-notdlg class to the elements you don’t want to render in a popup. Offcourse! Stupid!

I added the class but damn… still no joy. I found a post from Ben Ramey where he explained the same behavior if you forgot the <SharePoint:CssLink runat=”server” Version=”4″ />. But this tag was included in my masterpage. So, this was not the reason.

I started comparing an OOTB masterpage with mine and starting changing small things here and there, testing along the way.
And I found the culprit… it was the runat=“server” attribute on the <html> tag which wasn’t in mine. After I added it, the tags which had the s4-notdlg class didn’t render in a dialog anymore.

Another thing I noticed was that some items didn’t show up directly in the CQWP. Even if I checked them in. Did some searching and I stumbled on an article of Michael Nemtsev where he explains this and gives a workaround. (Why Content Query Web Part (CQWP) doesn’t return all results)

VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

Use a Custom ringtone on WP7 Mango

With Windows Phone 7 Mango, it’s now possible to use custom ringtones.
However, you have to know how to do this because simply transfering any mp3 to your phone is not going to work. There are some constraints.…
Your ringtone has to be:

  • a .WMA or .MP3
  • max 1Mb in size
  • about 30 sec. long (don’t know the correct length, but if you keep it below 30sec, it will definitely work)
  1. Connect your phone to your PC
  2. Load the ringtone to the folder where it’s picked up by Zune.
  3. In Zune, right-click the ringtone and select Edit.
  4. In the Genre field, type “Ringtone”.
  5. Transfer the ringtone to your phone

On your phone, go to Settings => Ringtones + Sounds en there you will find your custom ringtone.

 

 

VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

SharePoint Builds summarized

I’m often troubled with SharePoint deployments where you need to find out which version they have installed.

That’s easy, right? You just open up Central Administration, look at the Servers in the farm and woila, you have the build. Finding out which CU that is, is (again) very easy using Google. But sometimes you get an overload of information. I noticed that there is a lot of information out there which is simple wrong! Wrong build numbers, wrong articles, outdated links… So, I decided to get it over with and put em all in an Excel sheet. Done with googling around, wresting through KB’s and so on.

Just a plain and simple Excel sheet with the version, the KB number and a link to the KB article and this for MOSS 2007, WSS 3.0, SharePoint 2010 (SPS and SPF). This way, I always have that information at hand when I’m working at a customer. I just have to keep in mind that I need to update it when a new hotfix is released. 8-)

You can download the Excel sheet here: SharePoint Versions

If you notice that some information is wrong, please let me know. I tried to get it right, but I’m not perfect. ;-)

VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)

Extend VHD’s using VhdResizer

When you create a VHD, you have to specify the size of the disk. Once you reach that size, you will receive a out of free disk space message.

Fortunately, there is an easy way to extend your VHD. There is a tool called VhdResizer. This small tool enables you to resize an existing VHD. After you resize your disk, your VHD is still not extended. You still need to run the Disk Management utility from Windows to extend the volume.

So, here are the steps to make your existing VHD bigger…

Continue reading

VN:F [1.9.14_1148]
Rating: 0 (from 0 votes)