Friday, April 16, 2010

Sitecore Rendering Parameters – Friday Gotcha


One of the things I’ve learnt today is that Rendering Parameters is an extremely cool feature of Sitecore .NET CMS. It really empowers your editors by giving them ability to tweak parameters of your renderings in a very easy and intuitive way.

Tuesday, April 06, 2010

Visual Studio 2010 RC Intellisense Crash Issue


As many of you, I am developing with VS 2010 since the RC release. There are no issues discovered so far in terms of working with Sitecore .NET CMS, which is truly great but I have been having one annoying issue with the IDE crashing very often. I noticed that this was mainly happening when I was typing and intellisense was triggered. Immediately after it, the application crashed.
After a quick search, I’ve found the two hotfixes that were supposed to help (more about this here and here):
https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=26662
https://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=27019

The only problem was that the installation of these updates were failing, making it to the middle on the process and then rolling back.

I’ve tried different suggestions, like this one, hinting that closing daemon tools and Skype should help. I also stopped the W3SVC service, SQL service and reinstalled. This time it worked great! Now I am a happy camper :-)

Monday, April 05, 2010

Sitecore Rich Text Field - Iframe gotcha


If you ever tried putting an iframe in the Rich Text Field, you probably got what I got:

Server Error in '/' Application.
Empty strings are not allowed.
Parameter name: name

To solve this you have at least two options:
1. Wrap your iframe with the xsl:template definition. This way the iframe will appear as a web control in the rich text editor, but will render fine on the content delivery.
<xsl:template match="*" mode="main">
     <iframe id="iframe" src="..."></iframe>
</xsl:template>

2. Turn off HtmlEditor.SupportWebControls setting in web.config:
<setting name="HtmlEditor.SupportWebControls" value="false"/>

The second option makes more sense since you don’t need to alter the rich text content. If you don’t paste webcontrols to the rich text field, go for it.

Friday, April 02, 2010

Sitecore Installation Wizard – disable search index update during install


OK, now after my April Fools joke, let’s talk about serious things around Sitecore .NET CMS. Such as how to speed up installation of Sitecore packages.
One of the things that improve the performance of the package installation is disabling the search index update temporarily via the following setting:

<setting name="Indexing.UpdateInterval" value="00:00:00" />

Setting this interval to all zeros actively disables the background index update job that maintains Sitecore’s search index.

While you can certainly do this manually, it is not always feasible since you need to edit web.config (have access to the server, etc) plus it restarts the application.

What you can do however is to add some logic to the Installation Wizard, specifically a flag to temporarily disable the search index updates during the package installation:
clip_image002

To make this happen, do the following:

1. Create the following class in your project and compile it.

namespace SCUSAINC.Custom.Packager
{
   using System;
   using Sitecore.Reflection;
   using Sitecore.Web.UI.HtmlControls;
   using Sitecore.Web.UI.Sheer;
   using Sitecore.Shell.Applications.Install.Dialogs.InstallPackage;

   public class CustomInstallPackageForm : InstallPackageForm
   {
      [HandleMessage("installer:setTaskId")]
      private void OnSetTaskId(Message message)
      {
         var obj = this as InstallPackageForm;
         ReflectionUtil.CallMethod(typeof(InstallPackageForm), obj, "SetTaskID", true, true, new object[] { message });
      }

      [HandleMessage("installer:commitingFiles")]
      private void OnCommittingFiles(Message message)
      {
         var obj = this as InstallPackageForm;
         ReflectionUtil.CallMethod(typeof(InstallPackageForm), obj, "OnCommittingFiles", true, true, new object[] { message });
      }

      protected Checkbox DisableIndexing;

      protected override void OnLoad(EventArgs e)
      {
         DisableIndexing.Checked = false;
         base.OnLoad(e);
      }

      protected override void OnNext(object sender, EventArgs formEventArgs)
      {
         base.OnNext(sender, formEventArgs);
         if (Active == "Installing" && DisableIndexing.Checked)
         {
            Sitecore.Configuration.Settings.Indexing.Enabled = false;
         }
      }

      protected override void EndWizard()
      {
         base.EndWizard();
         if (DisableIndexing.Checked)
         {
            DisableIndexing.Checked = false;
            Sitecore.Configuration.Settings.Indexing.Enabled = true;
         }
      }
   }
}

2. Copy the following file to the /sitecore/shell/override folder: \sitecore\shell\Applications\Install\Dialogs\Install package\Install Package.xml

3. Open this XML file

4. Change the CodeBeside reference in the XML source file to your custom name:

<WizardForm Application="Tools/Installer/InstallationWizard" CodeBeside="SCUSAINC.Custom.Packager.CustomInstallPackageForm,SCUSAINC.Custom ">

5. Add the checkbox definition to the XML source:

<WizardFormPage ID="Ready" Header="Ready to Install" Text="The wizard is ready to install the package. Click Install to install the package." Icon="People/32x32/Box_Software.png">
   <WizardFormIndent>
     <GridPanel Columns="2" CellPadding="2" Width="100%"></GridPanel>
     <Checkbox ID="DisableIndexing" Header="Disable search index update during the install" Checked="True" />
   </WizardFormIndent>
</WizardFormPage>

Based on my tests, this significantly decreases the installation time (up to a half), especially on high volume packages in terms of content items.

Special thanks to Paul from Sitecore Support and Sergey from the development team for the assistance with this!

Thursday, April 01, 2010

God Mode for Sitecore


While playing with Sitecore .NET CMS today, I discovered a hidden feature that was slipped into the product just recently in the latest update for 6.2. It is called God Mode and is pretty much the same as in Windows 7.

Just download this package and install on your local Sitecore instance.

***WARNING***
Please don’t try it in production environment since it is not meant for this.
***WARNING***

Expected to work with 6.1/6.2 releases.

Let me know what you think!