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!

Monday, March 29, 2010

Dreamcore is coming. Hope to see you in Boston!


If you read this, you may have already registered for Dreamcore or at least thought about it. For those who have not heard about it, this is the first Sitecore partner conference that offers huge opportunity to learn about cutting edge stuff we do with the products, do some networking, share experience and of course have fun!

I am proud to be presenting at developer tracks with the following topics. Here is the brief abstract of those:
- Data Retrieval Techniques with Sitecore
Everyone knows that Sitecore CMS gives you tons of options in every aspect of development. Knowing how to access Sitecore data is very important. Knowing what approach is more efficient for certain requirements is absolutely critical. In this session, I outline different use cases and covers multiple ways to address each of them using such methods as traditional data access API, Sitecore Query, Fast Query, Search Index, Database Crawler, Link Database, etc. After the session the attendee will be able to easily match a use case with the most appropriate and performing way to address it.
- Using Lucene.NET with Sitecore
This topic is related to “Data Retrieval Techniques with Sitecore” and goes deeper in exploration of Lucene.NET implementation in Sitecore. During this session the I will demonstrate the real world use case of this technology for the CMS reporting.

Our search analytics proved that Lucene is the most demanding topic on SDN, so hope it is appropriate.

Any feedback about the specifics of what you would like to see is appreciated!

Monday, March 15, 2010

Sitecore Friendly URLs and plus sign


One of the customers recently asked about using the plus sign in URLs, for example: http://localhost/news+events.aspx

There are at least two ways to accomplish this:
1. Allow “+” in item name via a configuration change
For this you will need to adjust the regular expression in the “ItemNameValidation” setting in web.config and make sure + sign is not  present in the “InvalidItemNameChars” setting.
2. Rely on the display name instead.