SlowCheetah and Sitecore

At my current project we have a lot of different config files. We have multiple:

–        web.config
–        app_config\connectionstrings.config
–        app_config\app_settings.config
–        app_config\include\project.config

We’ve set this up with SlowCheetahwhich is an awesome tool to easily transform config files based on the build we have selected.

When I first installed it, I happily added all my transforms to the files above, and I built. My Visual Studio AfterBuild step copies and pastes all my stuff across to my installed Sitecore instance, and I browsed to it. That’s when I got the following error:


Turns out, in my eagerness to deploy this, I forgot I actually copied ALL config files across to my local path, not just the one I’m building for. It seems that Sitecore does not like having multiple files like that in the Include folder. When I deleted those files, it was fixed.

After that, I removed the transforms from the AfterBuild step and now it’s happily building away. 


Custom ordered treelist

On a different blog platform, 3 years ago, I created the following entry, which I thought would be nice to have in my ‘own’ blog platform as well.

On a project I was working on recently all the banners were put into a common folder. In the common folder was a hierarchical structure, which would make it easier to find banners when I wanted to select them in my banners field. On the offside, if you have a lot of banners, it can become very difficult to find the one you want to change.

Current situation

In my case it would be sufficient if I could have the name of the parent item in front of the selected item.

To accomplish this, I needed to complete 3 tasks:

  1. Create a custom class that inherits the TreeList
  2. In the Core database, create the new field type
  3. Set our field type in the template

Create a custom class
This custom class needs to override the OnLoad method, since that calls the method we are actually interested in: RestoreState.

protected override void OnLoad(EventArgs args)
  Assert.ArgumentNotNull(args, "args");
  if (!Sitecore.Context.ClientPage.IsEvent)

Then we pretty much keep the original RestoreState the way it was as well, except for a few lines.

private void RestoreState()
  Listbox _listBox = (Listbox)FindControl(this.ID = "_selected");
  string[] strArray = this.Value.Split(new char[]{'|'});
  if (strArray.Length > 0)
    Database contentDatabase = Sitecore.Context.ContentDatabase;
    if (!string.IsNullOrEmpty(this.DatabaseName))
      contentDatabase = Factory.GetDatabase(this.DatabaseName);

    for (int i=0; i < strArray.Length; i++)
      string str = strArray[i];
      if (!string.IsNullOrEmpty(str))
        ListItem child = new ListItem();
        child.ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("I");
        child.Value = child.ID + "|"+ str;
        Item item = contentDatabase.GetItem(str);
        if (item != null)
          child.Header = item.Parent.DisplayName + ":" + item.DisplayName;
          child.Header = str + ' ' + Translate.Text("[Item not found]");


Because the base.OnLoad() runs first, the listbox is already filled. To prevent it from containing double values, we need to clear it first. Then we run through the selected values again, putting the displayname of its parent in front.

Now, all we need to do is add the following to the web.config, in the <controlsources> node.

<source mode="on" namespace="CustomTreeList" assembly="CustomTreeList" prefix="MyProject" />

Create the field type

What I did here was duplicate the TreeList type in the Core database, and set the control field to what we just added in the web.config, followed by the classname.

Set the field type
In the template where we have the field, we can now select the Custom Treelist we just added.

If we then check the banner field again, we get the following:

Thank you for reading, I hope this blog helps you.

If you have any suggestions or a better way, please let me know.

As commented on the original post:

To cause links in this field type to appear in the links database, you may want to duplicate the existing treelist entry in the /App_Config/FieldTypes.config file, and change only the name attribute in the new line to match the name of your custom field type.