<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Fire Breaks Ice » Sitecore</title>
	
	<link>http://firebreaksice.com</link>
	<description>Sitecore Tips and Best Practices by Mark Ursino, Sitecore MVP</description>
	<lastBuildDate>Mon, 16 Apr 2012 17:22:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/FireBreaksIceSitecore" /><feedburner:info uri="firebreaksicesitecore" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>Sitecore Gutter Icon to Indicate an Item is a Page</title>
		<link>http://firebreaksice.com/sitecore-gutter-icon-to-indicate-an-item-is-a-page/</link>
		<comments>http://firebreaksice.com/sitecore-gutter-icon-to-indicate-an-item-is-a-page/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 13:00:53 +0000</pubDate>
		<dc:creator>Mark Ursino</dc:creator>
				<category><![CDATA[Sitecore]]></category>

		<guid isPermaLink="false">http://firebreaksice.com/?p=594</guid>
		<description><![CDATA[Learn how to implement a custom Sitecore gutter icon to indicate if the data item is a page.<p><a href="http://firebreaksice.com/sitecore-gutter-icon-to-indicate-an-item-is-a-page/">Sitecore Gutter Icon to Indicate an Item is a Page</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></description>
			<content:encoded><![CDATA[<p class="intro">Sitecore&#8217;s flexibility allows developers to truly extend it beyond its features that come out of the box. One such extension point is creating a custom icon in the gutter of the content tree. Inspired by <a href="http://www.dansolovay.com/2011/11/creating-gutter-icon-for-proxies.html">a post by Dan Solovay</a>, I&#8217;ve decided to create my own custom gutter icon to indicate if a data item is a page.</p>
<p>The reason I decided to create this icon was to help identify to content editors which items in the tree are pages (and thus have URLs represented by their path) vs. which items are merely just data items to store data. The code is quite simple, and the icon and tooltip are overridable via two custom Sitecore settings.</p>
<p><strong>Features</strong>:</p>
<ul>
<li>Visually indicates what data items have a layout set.</li>
<li>Configurable icon and hover tooltip.</li>
<li>Clicking the icon opens the presentation details pop-up.</li>
</ul>
<p><img src="http://firebreaksice.com/wp-content/uploads/2012/03/page-gutter.jpg" alt="" title="Page Gutter" width="227" height="210" class="alignnone size-full wp-image-627" /></p>
<h2>The Code</h2>
<pre class="brush: csharp; title: ; notranslate">

using Sitecore;
using Sitecore.Configuration;
using Sitecore.Data.Items;
using Sitecore.Shell.Applications.ContentEditor.Gutters;

namespace CustomGutters
{
    public class PageGutterRenderer : GutterRenderer
    {

        protected override GutterIconDescriptor GetIconDescriptor(Item item)
        {
            if (string.IsNullOrEmpty(item[FieldIDs.LayoutField]))
            {
                return null;
            }

            string iconPath = Settings.GetSetting(&quot;PageGutter.Icon&quot;);

            if(string.IsNullOrEmpty(iconPath))
            {
                iconPath = &quot;People/32x32/monitor2.png&quot;;
            }

            string iconTooltip = Settings.GetSetting(&quot;PageGutter.Tooltip&quot;);

            if (string.IsNullOrEmpty(iconTooltip))
            {
                iconTooltip = &quot;The item is a page.&quot;;
            }

            GutterIconDescriptor gutterIconDescriptor = new GutterIconDescriptor
            {
                Icon = iconPath,
                Tooltip = iconTooltip,
                Click = string.Format(&quot;item:setlayoutdetails(id={0})&quot;, item.ID)
            };

            return gutterIconDescriptor;
        }

    }
}
</pre>
<h2>Overrides</h2>
<p>The few lines of code that there are do come with two optional overrides:</p>
<p>To change the icon used in the gutter, create a Sitecore setting named <code>PageGutter.Icon</code> with the path to a Sitecore icon (e.g. &#8220;People/32&#215;32/monitor2.png&#8221;).</p>
<p>To change the tooltip on the icon, create a Sitecore setting named <code>PageGutter.Tooltip</code> with the desired text (e.g. &#8220;The item is a page.&#8221;).</p>
<h2>Download</h2>
<p>You can <a href="http://firebreaksice.com/wp-content/uploads/2012/03/Page_Custom_Gutter-2012.03.06.zip">download the DLL</a> for the compiled code and a <a href='http://firebreaksice.com/wp-content/uploads/2012/03/CustomGuttersDLL.zip'>Sitecore package which installs a single new gutter item in the core database</a>.
<p><a href="http://firebreaksice.com/sitecore-gutter-icon-to-indicate-an-item-is-a-page/">Sitecore Gutter Icon to Indicate an Item is a Page</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></content:encoded>
			<wfw:commentRss>http://firebreaksice.com/sitecore-gutter-icon-to-indicate-an-item-is-a-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Defensive Coding for Sitecore</title>
		<link>http://firebreaksice.com/defensive-coding-for-sitecore/</link>
		<comments>http://firebreaksice.com/defensive-coding-for-sitecore/#comments</comments>
		<pubDate>Sun, 26 Feb 2012 07:32:12 +0000</pubDate>
		<dc:creator>Mark Ursino</dc:creator>
				<category><![CDATA[Sitecore]]></category>

		<guid isPermaLink="false">http://firebreaksice.com/?p=572</guid>
		<description><![CDATA[Learn about my favorite defensive coding patterns and practices for Sitecore development.<p><a href="http://firebreaksice.com/defensive-coding-for-sitecore/">Defensive Coding for Sitecore</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></description>
			<content:encoded><![CDATA[<p class="intro">Inspired by a great post by Adam Weber about <a href="http://www.aweber1.com/sitecore-defensive-coding-practices">Sitecore Defensive Coding Practices</a>, I&#8217;ve decided to throw down some of my favorite patterns and practices with Sitecore Development. If you have any of your own, share them in the comments!</p>
<h2>Define a BaseSublayout Class</h2>
<p>Define a <code>BaseSublayout</code> class to expose base-level functionality to any UserControl/Sublayout that you will have on your site, e.g. <a href="http://firebreaksice.com/using-the-datasource-field-with-sitecore-sublayouts/" title="Using the DataSource Field with Sitecore Sublayouts">accessing a Data Source item</a>. For example:</p>
<pre class="brush: csharp; title: ; notranslate">

protected class PromoBox : BaseSublayout
{
	protected void Page_Load(object sender, EventArgs e)
	{
		// use any code exposed in the inherited class
	}
}
</pre>
<p><strong>My experience with this</strong>: I started doing this when I realized the power of assigning data source items to a sublayout defined on an item. The code to get a datasource takes a few lines, so I abstracted it into a base class for reusability on any project. It turns out John West has had something even better on Shared Source for a while now, the <a href="http://trac.sitecore.net/SublayoutParameterHelper/">Sublayout Parameter Helper</a>.</p>
<h2>Gracefully Degrade the Front-End</h2>
<p><strong>Note</strong>: This is not to be confused with the other graceful degradation pattern of front-end development, particularly with JavaScript. This is about accessing Sitecore data.</p>
<p>This is by far my favorite pattern that I use all the time. As developers, our job is to make the site render correctly per the content in Sitecore. That includes handling content editor errors that may occur, such as not filling out data or missing something. The concept is simple:</p>
<p>Set controls (ASP.NET controls, FieldRenderers, etc.) to be <code>visible="false"</code> by default, then prove the data to render exists and render the data. There are many sub-patterns you can go with here, depending on how you write your HTML and how the component works. For example, any sublayout I have that requires a DataSource is wrapped in a PlaceHolder with <code>visible="false"</code>. My job as a developer is to ensure a data source is set and its of the right template type. Once confirmed, I turn the placeholder&#8217;s visibility on. This pattern ensures no widow HTML exists that is rendered without any real data.</p>
<p>Here&#8217;s a simple example:</p>
<pre class="brush: plain; title: ; notranslate">
&lt;asp:PlaceHolder ID=&quot;TitleWithLinkPlaceholder&quot; runat=&quot;server&quot; Visible=&quot;false&quot;&gt;
	&lt;h4&gt;
		&lt;asp:Hyperlink ID=&quot;TitleWithLinkHyperlink&quot; runat=&quot;server&quot;&gt;
			&lt;sc:Text ID=&quot;TitleWithLinkText&quot; runat=&quot;server&quot; Field=&quot;Title&quot; /&gt;
		&lt;/asp:Hyperlink&gt;
	&lt;/h4&gt;
&lt;/asp:PlaceHolder&gt;
</pre>
<pre class="brush: csharp; title: ; notranslate">
bool linkSet = !String.IsNullOrEmpty(genericCallout.Link.Url);

if (!string.IsNullOrEmpty(genericCallout.Title.Text))
{
	if (linkSet) // With link
	{
		TitleWithLinkHyperlink.NavigateUrl = genericCallout.Link.Url;
		TitleWithLinkText.Item = genericCallout.InnerItem;
		TitleWithLinkPlaceholder.Visible = true;
	}
	//...
</pre>
<p>As you can see above, I assume the data is not in Sitecore by wrapping my HTML in a placeholder that is <code>visible="false"</code> then in C#, I see if the data exists and turn the controls on. In this simple example, it prevents a random <code>&lt;h4&gt;</code> tag from appears with nothing in it. Is it a lot of code for a little check like this? Yes. Is it worth it when not all fields in Sitecore are required and they affect the front-end? YES!</p>
<h2>Use FieldRenders or at Least Trigger the <code>renderField</code> Pipeline</h2>
<p>Many Sitecore solutions need to support Page Edit mode. In order for code to support this, the <code>renderField</code> pipeline needs to be triggered. Why? Because this pipeline injects JavaScript and JSON into the page in Page Edit mode to allow for dynamic control of the page. Triggering this can be done by using <code>FieldRenderer</code> controls on the front-end when possible, or if not possible, at least use the <code>FieldRenderer</code> via C#. Luckily, the <a href="http://trac.sitecore.net/CustomItemGenerator">Custom Item Generator</a> (CIG) exposes easy access to the <code>Rendered</code> value of a field, so at least use this if you need to use regular .NET controls. (<strong>Note</strong>: the CIG is another useful pattern Adam covers in his post).</p>
<h2>Use a Page Load Pattern with Try-Catch Blocks</h2>
<p>Every sublayout I write follows the same pattern:</p>
<ol>
<li>The <code>Page_Load</code> method body contains a try-catch block.</li>
<li>The try block calls a helper method to do the main work.</li>
<li>If the sublayout takes a <code>DataSource</code>, a check occurs to ensure the item is set and is of the right template.</li>
<li>The catch block logs the exception to the Sitecore log with the name of the specific sublayout.</li>
</ol>
<p>Here&#8217;s an example where we use several of the patterns in this blog post (BaseSublayout to expose the DataSource, CIG items, <code>Page_Load</code> pattern):</p>
<pre class="brush: csharp; title: ; notranslate">

protected void Page_Load(object sender, EventArgs e)
{
	try
	{
		if(DataSource != null &amp;&amp; DataSource.TemplateId.Equals(PromoItem.TemplateId.ToString()))
		{
			LoadPromo(DataSource);
		}
	}
	catch(Exception ex)
	{
		Sitecore.Diagnostics.Log.Error(&quot;Promo Sublayout&quot;, ex, this);
	}
}
</pre>
<p>In the above code, the method <code>LoadPromo(Item item)</code> would actually bind the data to controls, etc.</p>
<p><strong>My experience with this</strong>: I started doing this when I found it hard to determine where some <code>null</code> errors were occurring on sublayouts that didn&#8217;t have appropriate <code>null</code> checks. I started to follow the same pattern over and over and eventually tacked on the try-catch with Sitecore logging to make it easier to know when issues came up.</p>
<h2>Avoid Hard-coded Paths and Instead Expose Global Item Links</h2>
<p>To explain this approach, let me pose a scenario:</p>
<p>Say you&#8217;re building a search results page on your site to host the results sublayout for your global full text site search (using Lucene.NET, or Coveo, or Google Search Appliance, etc.). You have a textbox in your header that handles the search query and you push the query to the results page to actually search the site. How does your code for the textbox know which page to go to for the results?</p>
<ul>
<li><strong>Option 1</strong>: hard-code it (BLAH!)</li>
<li><strong>Option 2</strong>: expose a global field in Sitecore to set the results page (FTW!)</li>
</ul>
<p><img src="http://firebreaksice.com/wp-content/uploads/2012/02/global-pointer.jpg" alt="" title="Global Pointer" width="520" height="205" class="alignnone size-full wp-image-602" /></p>
<p>In code, your search box query method would do something like this:</p>
<pre class="brush: csharp; title: ; notranslate">

protected void btnSearch_Click(object sender, EventArgs e)
{

	// assumes Globals.GlobalItem is a static helper class to get the globals item
	ReferenceField searchPage = Globals.GlobalItem.Fields[&quot;Search Page&quot;];
	var url = LinkManager.GetItemUrl(searchPage.TargetItem) + &quot;?q=&quot; + txtSearch;
	Response.Redirect(url);

}
</pre>
<p>Why is Option 2 better? If someone renames the search results page, say from <code>search-results</code> to just <code>results</code> then the global field in Sitecore would handle the change.</p>
<h2>For Any Standard User Control in Use, Consider Statically Binding it as a Sublayout</h2>
<p>If your code in layouts and sublayouts references other modular controls such as standard users controls, e.g. <code>&lt;uc:Promo runat="server"&gt;&lt;/uc:Promo&gt;</code> you should consider loading the user controls the Sitecore way. By changing a standard user control reference to a statically bound sublayout, you can leverage Sitecore&#8217;s HTML output cache to cache the rendered HTML per the business rules of the control. E.g. <code>&lt;sc:Sublayout Path="~/path/to/your/control.ascx" Cacheable="true" runat="server" /&gt;</code>, then in C# you could perhaps set the <code>VaryByParm</code> property to alter the cache instances by your uniqueness of the control.</p>
<h2>Leverage Utility Classes, Do Not Reinvent</h2>
<p>Sitecore comes with a <a href="http://www.markstiles.net/Blog/2011/02/28/sitecore-util-classes.aspx">plethora of utility classes in many namespaces</a>. Learn them and use them. They&#8217;re very handy and you can avoid writing code that may already exist (e.g. <a href="http://firebreaksice.com/easily-sanitize-a-sitecore-item-name-in-csharp/" title="Easily Sanitize a Sitecore Item Name in C#">sanitizing an item name</a>).
<p><a href="http://firebreaksice.com/defensive-coding-for-sitecore/">Defensive Coding for Sitecore</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></content:encoded>
			<wfw:commentRss>http://firebreaksice.com/defensive-coding-for-sitecore/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Easily Sanitize a Sitecore Item Name in C#</title>
		<link>http://firebreaksice.com/easily-sanitize-a-sitecore-item-name-in-csharp/</link>
		<comments>http://firebreaksice.com/easily-sanitize-a-sitecore-item-name-in-csharp/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 13:00:32 +0000</pubDate>
		<dc:creator>Mark Ursino</dc:creator>
				<category><![CDATA[Sitecore]]></category>

		<guid isPermaLink="false">http://firebreaksice.com/?p=549</guid>
		<description><![CDATA[Learn how to easily sanitize a Sitecore item name when programmatically creating it.<p><a href="http://firebreaksice.com/easily-sanitize-a-sitecore-item-name-in-csharp/">Easily Sanitize a Sitecore Item Name in C#</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></description>
			<content:encoded><![CDATA[<p class="intro">Say you&#8217;re creating a new Sitecore item programmatically in C#. The general approach is to take some piece of data from your original data point, e.g. an article in a feed, and sanitize it so your item name is valid in Sitecore. Let&#8217;s take the example of an article&#8217;s title. Most developers will strip out the invalid character&#8217;s they can think would cause issues in Sitecore, e.g. !,.:; etc&#8230;</p>
<p>Here&#8217;s an easier way to do it with Sitecore&#8217;s own configuration:</p>
<pre class="brush: csharp; title: ; notranslate">
char[] invalidcharacters = Sitecore.Configuration.Settings.InvalidItemNameChars;
string sanitizedName = string.Concat(possibleName.Trim().Split(invalidcharacters));
</pre>
<p>Notice <code>Sitecore.Configuration.Settings.InvalidItemNameChars</code> gives you a character array of the characters defined in the <code>web.config</code>. From there, we just trim whitespace away from the name, split the string at each &#8220;invalid&#8221; character and then concatenate the split chunks.</p>
<p>For re-usability, here it is as an overloaded extension method:</p>
<pre class="brush: csharp; title: ; notranslate">
public static string SanitizeToItemName(this string possibleName)
{
  return SanitizeToItemName(possibleName, Sitecore.Configuration.Settings.InvalidItemNameChars);
}

public static string SanitizeToItemName(this string possibleName, char[] invalidCharacters)
{
  return string.Concat(possibleName.Trim().Split(invalidCharacters));
}
</pre>
<p><strong>UPDATE:</strong></p>
<p><a href="http://www.markvanaalst.com/">Mark van Aalst</a> identified that the Sitecore API has a utility method that does something like this already: <code>Sitecore.Data.Items.ItemUtil.ProposeValidItemName(name, defaultValue);</code>. Thanks for the tip Mark!
<p><a href="http://firebreaksice.com/easily-sanitize-a-sitecore-item-name-in-csharp/">Easily Sanitize a Sitecore Item Name in C#</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></content:encoded>
			<wfw:commentRss>http://firebreaksice.com/easily-sanitize-a-sitecore-item-name-in-csharp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Programmatically Add Controls to the HTML Head in Sitecore</title>
		<link>http://firebreaksice.com/programmatically-add-controls-to-the-html-head-in-sitecore/</link>
		<comments>http://firebreaksice.com/programmatically-add-controls-to-the-html-head-in-sitecore/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 00:00:02 +0000</pubDate>
		<dc:creator>Mark Ursino</dc:creator>
				<category><![CDATA[Sitecore]]></category>

		<guid isPermaLink="false">http://firebreaksice.com/?p=563</guid>
		<description><![CDATA[Learn how to programmatically add controls to the HTML Head tag via the Sitecore API.<p><a href="http://firebreaksice.com/programmatically-add-controls-to-the-html-head-in-sitecore/">Programmatically Add Controls to the HTML Head in Sitecore</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></description>
			<content:encoded><![CDATA[<p class="intro">I was recently working on a Sitecore module and realized I needed to add some HTML elements to the <code>&lt;head&gt;</code> tag of pages using the module. This would normally be something that can be done directly in every layout, but because this is a Sitecore module, I wanted to do it dynamically via C# through a pipeline so that it would only require a configuration patch to inject my code. The challenge I had was not implementing it via a pipeline processor, but rather programmatically getting access to the <code>&lt;head&gt;</code> tag. Luckily, <a href="http://sdn.sitecore.net/forum//ShowPost.aspx?PostID=42929#42938">John West had a great solution</a>, and it was something directly available via the Sitecore API.</p>
<p>First, to accomplish this, register a processor for the <code>renderLayout</code> pipeline:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;renderLayout&gt;
  &lt;processor type=&quot;MyLibrary.Pipelines.RenderLayout.InsertHeadControls, MyLibrary&quot;&gt;
  ...
&lt;/renderLayout&gt;
</pre>
<p>Next, let&#8217;s look at the code:</p>
<pre class="brush: csharp; title: ; notranslate">

namespace MyLibrary.Pipelines.RenderLayout
{
  public class InsertHeadControls
  {
    public void Process(RenderLayoutArgs args)
    {

      // no need to run our code in the shell
      if(Sitecore.Context.Site.Name == &quot;shell&quot;)
        return;

      Control head = WebUtil.FindControlOfType(Sitecore.Context.Page.Page, typeof(HtmlHead));
      if(head != null)
      {
        head.Controls.Add(/* add whatever control you want */);
      }
    }
  }
}
</pre>
<p>The key here was to use <code>WebUtil.FindControlOfType()</code> to get the <code>HtmlHead</code> control via C#. From there you can ensure its not null and add controls dynamically to it as needed. Note: for the HtmlHead to not be null, I believe this requires a <code>runat="server"</code> on the <code>&lt;head&gt;</code> tag.
<p><a href="http://firebreaksice.com/programmatically-add-controls-to-the-html-head-in-sitecore/">Programmatically Add Controls to the HTML Head in Sitecore</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></content:encoded>
			<wfw:commentRss>http://firebreaksice.com/programmatically-add-controls-to-the-html-head-in-sitecore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prevent Sitecore Content Editor From Stripping Script Tags</title>
		<link>http://firebreaksice.com/prevent-sitecore-content-editor-from-stripping-script-tags/</link>
		<comments>http://firebreaksice.com/prevent-sitecore-content-editor-from-stripping-script-tags/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 22:09:16 +0000</pubDate>
		<dc:creator>Mark Ursino</dc:creator>
				<category><![CDATA[Sitecore]]></category>

		<guid isPermaLink="false">http://firebreaksice.com/?p=534</guid>
		<description><![CDATA[Learn how to prevent Sitecore's Rich Text Editor from stripping JavaScript tags.<p><a href="http://firebreaksice.com/prevent-sitecore-content-editor-from-stripping-script-tags/">Prevent Sitecore Content Editor From Stripping Script Tags</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></description>
			<content:encoded><![CDATA[<p class="intro">I was recently helping a colleague with writing some custom buttons in the Telerik Rich Text Editor. Our button injects JavaScript into the content of the field and we noticed some of the JavaScript was being stripped by Telerik. This has been an annoying issue for many versions of Sitecore. The solution is quite simple and requires a small change to a built-in Sitecore file.</p>
<p>Telerik&#8217;s documentation explains a <a href="http://www.telerik.com/help/aspnet-ajax/editor-content-filters.html">content filter</a> that can be applied to strip script tags. The goal of the custom code it to override the Telerik editor and <a href="http://sdn.sitecore.net/forum//ShowPost.aspx?PostID=42668">disable the filter from being applied</a>.</p>
<p>Open <code>\Website\sitecore\shell\Controls\Rich Text Editor\EditorPage.aspx</code></p>
<p>The C# is compiled in the <code>Sitecore.Client.dll</code> assembly, so let&#8217;s add in our own C# code right into this page. Add in the following block of code to run before the normal <code>Page_Load</code>:</p>
<pre class="brush: csharp; title: ; notranslate">
&lt;script runat=&quot;server&quot;&gt;

   protected override void OnLoad(EventArgs e)
   {
       Editor.DisableFilter(EditorFilters.RemoveScripts);
       base.OnLoad(e);
   }

&lt;/script&gt;
</pre>
<p><strong>Note</strong>: this was tested on Sitecore 6.4</p>
<p>Just consider the upgrade path here. Before you run an upgrade of Sitecore you&#8217;d want to backup this built-in file just in case.</p>
<p><strong>Update (1/19/2012)</strong></p>
<p>While working with a colleague (<a href="http://sdn.sitecore.net/MVP/MVPs/Mark%20Graber.aspx">Mark Graber, Sitecore MVP</a>) we determined a better way to do this via a configuration patch so you don&#8217;t need to edit the built-in Sitecore editor page.</p>
<p>Create a class that inherits <code>Sitecore.Shell.Controls.RichTextEditor.EditorConfiguration</code>. Next, override the <code>SetupFilters()</code> method and in there run the same code to remove the filter, like so:</p>
<pre class="brush: csharp; title: ; notranslate">
protected override void SetupFilters()
{
  Editor.DisableFilter(EditorFilters.RemoveScripts);
  base.SetupFilters();
}
</pre>
<p>Now, register this new class in the config setting &#8220;HtmlEditor.DefaultConfigurationType&#8221; like so:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;setting name=&quot;HtmlEditor.DefaultConfigurationType&quot; value=&quot;MyProject.EditorConfiguration, MyProject&quot;/&gt;
</pre>
<p><strong>Update (2/16/2012)</strong></p>
<p>It has been reported (in the comments) that there is still an issue that scripts are removed when you switch to HTML view of the RTE. I was only able to reproduce this issue in Internet Explorer but it does appear to be a problem still.</p>
<p>Additionally, it appears newer releases of Sitecore have the above solution baked in with a new setting called <code>HtmlEditor.RemoveScripts</code> which affects the built-in <code>EditorConfiguration</code> class based on the setting. My post was written on 1/10/2012 and <a href="http://sdn.sitecore.net/SDN5/Products/Sitecore%20V5/Sitecore%20CMS%206/ReleaseNotes/webConfig/641_120113.aspx">Update 6 to Sitecore 6.4.1 was released on 1/13/2012</a> with this setting. So this should now be a built-in setting to Sitecore which will make it easier to configure out of the box!
<p><a href="http://firebreaksice.com/prevent-sitecore-content-editor-from-stripping-script-tags/">Prevent Sitecore Content Editor From Stripping Script Tags</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></content:encoded>
			<wfw:commentRss>http://firebreaksice.com/prevent-sitecore-content-editor-from-stripping-script-tags/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Rendering Fully Qualified Sitecore URLs</title>
		<link>http://firebreaksice.com/rendering-fully-qualified-sitecore-urls/</link>
		<comments>http://firebreaksice.com/rendering-fully-qualified-sitecore-urls/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 17:15:14 +0000</pubDate>
		<dc:creator>Mark Ursino</dc:creator>
				<category><![CDATA[Sitecore]]></category>

		<guid isPermaLink="false">http://firebreaksice.com/?p=530</guid>
		<description><![CDATA[Sitecore&#8217;s web.config contains many ways to extend and customize the application. One such configurable aspect is dynamic link resolution. This article is intended to explain how you can configure Sitecore to render fully qualified URLs (e.g. http://host/my/path/to/page.aspx) in links. Make All Links Fully Qualified Its really easy to configure Sitecore to make all links fully [...]<p><a href="http://firebreaksice.com/rendering-fully-qualified-sitecore-urls/">Rendering Fully Qualified Sitecore URLs</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></description>
			<content:encoded><![CDATA[<p class="intro">Sitecore&#8217;s <code>web.config</code> contains many ways to extend and customize the application. One such configurable aspect is dynamic link resolution. This article is intended to explain how you can configure Sitecore to render fully qualified URLs (e.g. <code>http://host/my/path/to/page.aspx</code>) in links.</p>
<h2>Make All Links Fully Qualified</h2>
<p>Its really easy to configure Sitecore to make all links fully qualified. You can simply update the <code>linkManager</code> configuration and set <code>alwaysIncludeServerUrl</code> to <code>true</code>. Here&#8217;s an example:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;linkManager defaultProvider=&quot;sitecore&quot;&gt;
  &lt;providers&gt;
    &lt;clear /&gt;
    &lt;add name=&quot;sitecore&quot; type=&quot;Sitecore.Links.LinkProvider, Sitecore.Kernel&quot; addAspxExtension=&quot;true&quot; alwaysIncludeServerUrl=&quot;true&quot; encodeNames=&quot;true&quot; languageEmbedding=&quot;never&quot; languageLocation=&quot;filePath&quot; shortenUrls=&quot;true&quot; useDisplayName=&quot;false&quot; /&gt;
  &lt;/providers&gt;
&lt;/linkManager&gt;
</pre>
<h2>Only Make Some Links Fully Qualified</h2>
<p>If you don&#8217;t always want all links to be fully qualified, but rather have certain scenarios when they should be, you can create a custom link provider to handle this. Simply inherit <code>Sitecore.Links.LinkProvider</code> and override the <code>GetItemUrl(...)</code> method:</p>
<pre class="brush: csharp; title: ; notranslate">
namespace CustomLibrary.Links
{
    public class CustomLinkProvider : Sitecore.Links.LinkProvider
    {

        public override string GetItemUrl(Sitecore.Data.Items.Item item, Sitecore.Links.UrlOptions options)
        {

            if (/* my condition of when to apply fully qualified links, e.g. a specific device maybe */)
            {

                options.AlwaysIncludeServerUrl = true;

            }

            return base.GetItemUrl(item, options);
        }

    }
}
</pre>
<p>After doing this, change the <code>defaultProvider</code> in the <code>linkManager</code> to your custom class like so:</p>
<pre class="brush: xml; title: ; notranslate">

&lt;linkManager defaultProvider=&quot;custom&quot;&gt;
  &lt;providers&gt;
    &lt;clear /&gt;
    &lt;add name=&quot;sitecore&quot; type=&quot;Sitecore.Links.LinkProvider, Sitecore.Kernel&quot; addAspxExtension=&quot;true&quot; alwaysIncludeServerUrl=&quot;false&quot; encodeNames=&quot;true&quot; languageEmbedding=&quot;never&quot; languageLocation=&quot;filePath&quot; shortenUrls=&quot;true&quot; useDisplayName=&quot;false&quot; /&gt;
    &lt;add name=&quot;custom&quot; type=&quot;CustomLibrary.Links.CustomLinkProvider, CustomLibrary&quot; addAspxExtension=&quot;true&quot; alwaysIncludeServerUrl=&quot;false&quot; encodeNames=&quot;true&quot; languageEmbedding=&quot;never&quot; languageLocation=&quot;filePath&quot; shortenUrls=&quot;true&quot; useDisplayName=&quot;false&quot; /&gt;
  &lt;/providers&gt;
&lt;/linkManager&gt;
</pre>
<p><a href="http://firebreaksice.com/rendering-fully-qualified-sitecore-urls/">Rendering Fully Qualified Sitecore URLs</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></content:encoded>
			<wfw:commentRss>http://firebreaksice.com/rendering-fully-qualified-sitecore-urls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scaling Sitecore Presentation Component Data Sources</title>
		<link>http://firebreaksice.com/scaling-sitecore-presentation-component-data-sources/</link>
		<comments>http://firebreaksice.com/scaling-sitecore-presentation-component-data-sources/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 13:00:46 +0000</pubDate>
		<dc:creator>Mark Ursino</dc:creator>
				<category><![CDATA[Sitecore]]></category>

		<guid isPermaLink="false">http://firebreaksice.com/?p=469</guid>
		<description><![CDATA[Sitecore presentation components come with some handy features to make them reusable, such as assigning a data source to define dynamic data. This post will explain how to scale your data sources so they can be moved or renamed within the content tree without affecting presentation. The Issue (the Internal Link field) The Data Source [...]<p><a href="http://firebreaksice.com/scaling-sitecore-presentation-component-data-sources/">Scaling Sitecore Presentation Component Data Sources</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></description>
			<content:encoded><![CDATA[<p class="intro">Sitecore presentation components come with some handy features to make them reusable, such as <a href="http://firebreaksice.com/using-the-datasource-field-with-sitecore-sublayouts/" title="Using the DataSource Field with Sitecore Sublayouts">assigning a data source to define dynamic data</a>. This post will explain how to scale your data sources so they can be moved or renamed within the content tree without affecting presentation.</p>
<h2>The Issue (the Internal Link field)</h2>
<p>The <strong>Data Source</strong> field on component rendering parameters is unfortunately set as an Internal Link field, so if you move or rename the target data source item, your presentation components that use the data source will break. This is because an Internal Link field (<a href="http://firebreaksice.com/sitecore-internal-links/" title="Sitecore Internal Links">which you should always avoid</a>) stores the target item via path, not GUID, so renaming or moving it will cause the path to be wrong.</p>
<h2>A Simple Solution</h2>
<p>This issue is quite annoying and can cause developers and/or architects to avoid using data sources and instead opt for <a href="http://blog.igloo.com.au/?p=4168">Parameter Data Templates</a>. The solution is to merely change the out-of-the-box <strong>Data Source</strong> field to be a Droptree field instead of an Internal Link field. Here&#8217;s how to do it.</p>
<p>First, find the template with the <strong>Data Source</strong> field on it. It happens to be on the <strong>Standard Rendering Parameters</strong> template (<code>/sitecore/system/Layout/Rendering Parameters/Standard Rendering Parameters</code>) which all presentation components use in the control properties.</p>
<p><img src="http://firebreaksice.com/wp-content/uploads/2012/01/datasources1.jpg" alt="" title="Standard Rendering Parameters" width="278" height="513" class="alignnone size-full wp-image-513" /></p>
<p>Next, change the <strong>Data Source</strong> field to be a droptree.</p>
<p><a href="http://firebreaksice.com/wp-content/uploads/2012/01/datasources2.jpg"><img src="http://firebreaksice.com/wp-content/uploads/2012/01/datasources2.jpg" width="600" height="130" alt="" title="Droptree" width="885" height="192" class="alignnone size-full wp-image-514" /></a></p>
<p>Now, when you pick a data source, it will use a Droptree field and store the target item via GUID, so renaming or moving it will not break anything.</p>
<p><a href="http://firebreaksice.com/wp-content/uploads/2012/01/datasources3.jpg"><img src="http://firebreaksice.com/wp-content/uploads/2012/01/datasources3.jpg" width="600" height="260" alt="" title="A new Data Source" width="772" height="335" class="alignnone size-full wp-image-515" /></a></p>
<p>I&#8217;ve tested how Sitecore&#8217;s interface reacts to this change and Page Edit mode still works when assigning a data source item to a component.
<p><a href="http://firebreaksice.com/scaling-sitecore-presentation-component-data-sources/">Scaling Sitecore Presentation Component Data Sources</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></content:encoded>
			<wfw:commentRss>http://firebreaksice.com/scaling-sitecore-presentation-component-data-sources/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A Going Live Checklist for Sitecore Websites</title>
		<link>http://firebreaksice.com/a-going-live-checklist-for-sitecore-websites/</link>
		<comments>http://firebreaksice.com/a-going-live-checklist-for-sitecore-websites/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 20:08:25 +0000</pubDate>
		<dc:creator>Mark Ursino</dc:creator>
				<category><![CDATA[Sitecore]]></category>

		<guid isPermaLink="false">http://firebreaksice.com/?p=487</guid>
		<description><![CDATA[Here's a list of items to consider when launching a Sitecore site live. They're broken down into security and performance tips.<p><a href="http://firebreaksice.com/a-going-live-checklist-for-sitecore-websites/">A Going Live Checklist for Sitecore Websites</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></description>
			<content:encoded><![CDATA[<p class="intro">This post is a summation of many different points to consider when deploying a Sitecore site to the public. Many of these are .NET tips that apply, but most are specific to Sitecore solutions. The checklist is broken down into two main categories: <a href="http://firebreaksice.com/a-going-live-checklist-for-sitecore-websites#security">Security</a> and <a href="http://firebreaksice.com/a-going-live-checklist-for-sitecore-websites#performance">Performance</a>.</p>
<h2 id="security">I. Security</h2>
<h3>1. Protect Admins Pages</h3>
<p>Some of the older versions of Sitecore do not protect the <a href="http://firebreaksice.com/sitecore-admin-pages-explained/">admin pages</a> under the <code>/sitecore/admin/</code> folder. You should block public access to these by implementing security via IIS configuration. You can read how to do this in section 2.3 of the <a href="http://sdn.sitecore.net/Reference/Sitecore%206/Security%20Hardening%20Guide.aspx">Security Hardening Guide</a> (for 6.0 &#8211; 6.4).</p>
<h3>2. Turn on Custom Errors</h3>
<p>Remember to update your production <code>web.config</code> to <code>&lt;customErrors mode="RemoteOnly" /&gt;</code>. This will allow to you have a friendly error message to your site visitors should an error occur.</p>
<h3>3. Secure the Sitecore Backend</h3>
<p>Don&#8217;t forget to reset the admin user&#8217;s password. It would be quite embarrassing to go live with &#8220;b&#8221; as your password.</p>
<h3>4. Deploy Your Real License File</h3>
<p>Ensure a live license file is deployed, not a temporary license or partner development license.</p>
<h2 id="performance">II. Performance</h2>
<h3>1. Configure Keep-Alive</h3>
<p>Update your <code>web.config</code> to set the <code>UrlAgent</code> to the public URL of your site&#8217;s keep-alive page. By default the URL is not fully qualified and therefore a web request cannot be made to it, so just update it with your hostname. Having this enabled will ensure the application pool&#8217;s worker process does not shut down.</p>
<pre class="brush: plain; title: ; notranslate">
&lt;agent type=&quot;Sitecore.Tasks.UrlAgent&quot; method=&quot;Run&quot; interval=&quot;01:00:00&quot;&gt;
  &lt;param desc=&quot;url&quot;&gt;/sitecore/service/keepalive.aspx&lt;/param&gt;
  &lt;LogActivity&gt;true&lt;/LogActivity&gt;
&lt;/agent&gt;
</pre>
<h3>2. Turn Debug Mode Off</h3>
<p>Remember to update your production <code>web.config</code> to <code>&lt;compilation debug="false"&gt;</code>. This will result in higher performance of the application since extra debug info doesn&#8217;t need to be processed.</p>
<h3>3. Regularly Rebuild Search Indexes</h3>
<p>If you&#8217;re using <code>Sitecore.Search</code>, ensure search indexes are set to rebuild on the public database (e.g. web). If you don&#8217;t regularly rebuild your search indexes, they can become fragmented and can degrade performance. One way to rebuild them regularly is to create a page that when requested rebuilds the indexes. You can use <a href="http://firebreaksice.com/automate-sitecore-tasks-with-wget/">Wget to automate executing this script</a>.</p>
<h3>4. Tune the Cache Sizes (Prefetch, Data, Item, and HTML Caches)</h3>
<p>It&#8217;s important to tune your cache sizes instead of using the out-of-the-box values. If you&#8217;re not sure how the many layers of the Sitecore cache works, read the <a href="http://learnsitecore.cmsuniverse.net/en/Developers/Articles/2009/07/CachingOverview.aspx">Caching Overview</a> by Jens Mikkelsen. Sitecore recommends some initial values in Chapter 5 of the <a href="http://sdn.sitecore.net/Reference/Sitecore%206/CMS%20Performance%20Tuning%20Guide.aspx">CMS Performance Tuning Guide</a>. As the guide mentions, remember to modify the Prefetch cache config as many of the default values are unnecessary and will waste system resources.</p>
<h3>5. Define Machine Keys to Load Balanced Servers</h3>
<p>If your CD environment contains multiple load balanced servers, make sure you apply the same <a href="http://msdn.microsoft.com/en-us/library/w8h3skw9%28VS.90%29.aspx">machine key</a> to all instances. To understand more about what you need to do, refer to section 4.5 of the <a href="http://sdn.sitecore.net/Reference/Sitecore%206/Scaling%20Guide.aspx">Scaling Guide</a>.</p>
<h3>6. Tweak Your Delivery Environment</h3>
<p>If you want more tips, Rick Cabral from ISITE Design has published a good guide on ways to <a href="http://www.isitedesign.com/sitecore/2011/04/18/tweak-your-sitecore-delivery-environment/">Tweak Your Sitecore Delivery Environment</a>.</p>
<h2>Your Tips</h2>
<p>What are your tips or checklist items you refer to when you launch a Sitecore site? Leave them in the comments below.
<p><a href="http://firebreaksice.com/a-going-live-checklist-for-sitecore-websites/">A Going Live Checklist for Sitecore Websites</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></content:encoded>
			<wfw:commentRss>http://firebreaksice.com/a-going-live-checklist-for-sitecore-websites/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Sort Sitecore Items in the Content Editor</title>
		<link>http://firebreaksice.com/how-to-sort-sitecore-items-in-the-content-editor/</link>
		<comments>http://firebreaksice.com/how-to-sort-sitecore-items-in-the-content-editor/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 14:00:55 +0000</pubDate>
		<dc:creator>Mark Ursino</dc:creator>
				<category><![CDATA[Sitecore]]></category>

		<guid isPermaLink="false">http://firebreaksice.com/?p=449</guid>
		<description><![CDATA[Learn how to sort items in the Sitecore content editor alphabetically by name (and other criteria).<p><a href="http://firebreaksice.com/how-to-sort-sitecore-items-in-the-content-editor/">How to Sort Sitecore Items in the Content Editor</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></description>
			<content:encoded><![CDATA[<p class="intro">We&#8217;ve previously seen <a title="How To Reset Individual Sitecore Fields to Standard Values" href="http://firebreaksice.com/how-to-reset-individual-sitecore-fields-to-standard-values/">how to reset individual fields in Sitecore to their standard values</a>, so today I&#8217;m going to show you how to re-order sub-items under a parent item. Many times you&#8217;d want to do this task if you&#8217;re creating a lot of items and would prefer them to be alphabetically ordered, or ordered by other criteria.</p>
<p>First, observe a folder of items ordered alphabetically. This is probably how you want them ordered, but let&#8217;s take a look at the sorting option available.</p>
<p><img class="alignnone size-full wp-image-450" title="Alphabetically Listed Items" src="http://firebreaksice.com/wp-content/uploads/2011/12/sort01.jpg" alt="" width="160" height="230" /></p>
<p>Right-click the parent item and go to <strong>Sorting &gt; Subitems Sorting</strong>.</p>
<p><img class="alignnone size-full wp-image-451" title="Subitems Sorting" src="http://firebreaksice.com/wp-content/uploads/2011/12/sort02.jpg" alt="" width="316" height="378" /></p>
<p>The pop-up allows you to define how to sort the items. There are many options in the dropdown to pick. In this example, Reverse has been selected to reverse the current order. The sorting option selected is previewed below in the main area.</p>
<p><img class="alignnone size-full wp-image-452" title="Sort by Reverse" src="http://firebreaksice.com/wp-content/uploads/2011/12/sort03.jpg" alt="" width="516" height="639" /></p>
<p>To actually cause the items to sort using this sorting criteria, many people forget or don&#8217;t know that you need to push the <strong>Reset</strong> button to cause them to re-sort.</p>
<p><img class="alignnone size-full wp-image-453" title="Reset Sort Order" src="http://firebreaksice.com/wp-content/uploads/2011/12/sort04.jpg" alt="" width="509" height="123" /></p>
<p>After hitting <strong>Reset</strong>, confirm you want to sort.</p>
<p><img class="alignnone size-full wp-image-454" title="Confirm Reset" src="http://firebreaksice.com/wp-content/uploads/2011/12/sort05.jpg" alt="" width="398" height="175" /></p>
<p>Next, click <strong>OK</strong> to close the sorting menu.</p>
<p><img class="alignnone size-full wp-image-455" title="OK to Reset" src="http://firebreaksice.com/wp-content/uploads/2011/12/sort06.jpg" alt="" width="507" height="126" /></p>
<p>As you can see, the items are now sorted in reverse alphabetical order.</p>
<p><img class="alignnone size-full wp-image-456" title="Items Sorted in Reverse Alpha Order" src="http://firebreaksice.com/wp-content/uploads/2011/12/sort07.jpg" alt="" width="161" height="229" /></p>
<p>If you ever need to sort items back to their original alphabetical order, you can use the <strong>[Reset to Standard Value]</strong> sorting option.</p>
<p><img class="alignnone size-full wp-image-457" title="Reset To Standard Values" src="http://firebreaksice.com/wp-content/uploads/2011/12/sort08.jpg" alt="" width="517" height="639" /></p>
<p>As you can see, the items are back in alphabetical order:</p>
<p><img class="alignnone size-full wp-image-458" title="Sorted by Alpha Again" src="http://firebreaksice.com/wp-content/uploads/2011/12/sort09.jpg" alt="" width="155" height="228" />
<p><a href="http://firebreaksice.com/how-to-sort-sitecore-items-in-the-content-editor/">How to Sort Sitecore Items in the Content Editor</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></content:encoded>
			<wfw:commentRss>http://firebreaksice.com/how-to-sort-sitecore-items-in-the-content-editor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Automate Sitecore Tasks with Wget</title>
		<link>http://firebreaksice.com/automate-sitecore-tasks-with-wget/</link>
		<comments>http://firebreaksice.com/automate-sitecore-tasks-with-wget/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 14:00:03 +0000</pubDate>
		<dc:creator>Mark Ursino</dc:creator>
				<category><![CDATA[Sitecore]]></category>

		<guid isPermaLink="false">http://firebreaksice.com/?p=431</guid>
		<description><![CDATA[There are many approaches out there to automate tasks for Sitecore. Here is one way to use Wget and the Windows Task Scheduler.<p><a href="http://firebreaksice.com/automate-sitecore-tasks-with-wget/">Automate Sitecore Tasks with Wget</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></description>
			<content:encoded><![CDATA[<p class="intro">There are <a href="#additional">many blog posts</a> out there about automating and scheduling Sitecore tasks. This post covers a scenario that I&#8217;ve used several times and just wanted to share. As <a href="http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog.aspx">John West</a> mentions in <a href="http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/11/All-About-Sitecore-Scheduling-Agents-and-Tasks.aspx">All About Sitecore Scheduling Agents and Tasks</a>, tasks defined in Sitecore and configured agents may not run on a site if the ASP.NET worker process has shut down due to inactivity to the site. This is often the case during off hours when you&#8217;d probably want to perform administrative tasks.</p>
<h2>Overview</h2>
<p>The scenario I often have is to rebuild the Lucene search indexes at off hours, usually around 3am, when the worker process can very well be shutdown due to inactivity. The process is simple: install Wget and configure a Windows scheduled task to call Wget to request a secret page on the site.</p>
<h2>Task Configuration</h2>
<ol>
<li>Download the <a href="http://gnuwin32.sourceforge.net/packages/wget.htm">Windows version of Wget</a> and install it on the server.</li>
<li>Create a new Windows Scheduled Task in the Control Panel.</li>
<li>Navigate to the Wget program for the task to run.</li>
<li>Once you create the task, right-click it and select Properties.</li>
<li>Modify the path of the task to include the <code>--spider</code> parameter and the URL to your page to run. Below is a sample line for a task path.</li>
</ol>
<pre class="brush: plain; title: ; notranslate">
&quot;C:\Program Files\wget-1.11.4-1-bin\bin\wget.exe&quot; --spider http://mysite.com/obfuscated-folder/special-task.aspx
</pre>
<p>This is just one of many ways to automate running something and have it happen at a specific time of the day. Here are some pros and cons I can think of for this approach:</p>
<h2>Pros</h2>
<ul>
<li>Guaranteed to run at a specific time since it doesn&#8217;t rely on ticks in Sitecore</li>
<li>Simple to setup and won&#8217;t require a config change and therefore won&#8217;t recycle an existing app</li>
<li>Since a secret page is exposed via a public URL, you can manually run the code by hitting the page</li>
</ul>
<h2>Cons</h2>
<ul>
<li>Isolated from the Sitecore app, and thus possibly forgotten if migrating a server</li>
<li>Requires a specific page on the site to be requested, meaning a page with secret code would be exposed publicly (this can easily be fixed via permissions)</li>
</ul>
<h2 id="additional">Additional Reading</h2>
<ul>
<li><a href="http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/11/All-About-Sitecore-Scheduling-Agents-and-Tasks.aspx">All About Sitecore Scheduling Agents and Tasks</a></li>
<li><a href="http://adeneys.wordpress.com/2011/03/17/long-running-process-options/">Long Running Process Options</a></li>
<li><a href="http://dmgdotnet.wordpress.com/2010/03/15/hello-world/">Sitecore – Publish via Scheduled Task</a></li>
<li><a href="http://sitecoreblog.blogspot.com/2011/01/use-sitecore-jobs.html">Use the sitecore jobs </a></li>
<li><a href="http://briancaos.wordpress.com/2011/06/28/run-sitecore-scheduled-task-at-the-same-time-every-day/">Run Sitecore scheduled task at the same time every day</a></li>
<li><a href="http://blog.istern.dk/2011/10/06/running-scheduledtasks-with-the-jobmanager-in-sitecore/">Running Scheduledtasks with the jobmanager in Sitecore</a></li>
</ul>
<p><a href="http://firebreaksice.com/automate-sitecore-tasks-with-wget/">Automate Sitecore Tasks with Wget</a> is a post from <a href="http://firebreaksice.com">Fire Breaks Ice</a>, published by Mark Ursino, Sitecore MVP</p>
]]></content:encoded>
			<wfw:commentRss>http://firebreaksice.com/automate-sitecore-tasks-with-wget/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Database Caching 1/47 queries in 0.770 seconds using disk: basic
Object Caching 894/984 objects using disk: basic

Served from: firebreaksice.com @ 2012-05-26 13:06:22 -->

