<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Codality &#187; EPiServer</title>
	<atom:link href="http://blog.najmanowicz.com/category/software-development/episerver/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.najmanowicz.com</link>
	<description>Code and Effect - solving problem with just enough amount of code - by Adam Najmanowicz</description>
	<lastBuildDate>Mon, 08 Feb 2010 12:01:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CMS UX &#8211; give the content some thought!</title>
		<link>http://blog.najmanowicz.com/2010/02/08/cms-ux-give-the-content-some-thought/</link>
		<comments>http://blog.najmanowicz.com/2010/02/08/cms-ux-give-the-content-some-thought/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 12:01:38 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CMS UX]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Faceted Navigation]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2010/02/08/cms-ux-give-the-content-some-thought/</guid>
		<description><![CDATA[One of the many things we debate constantly at Cognifide is how to improve the user experience. How to make editor’s life easier, how to simplify the common everyday tasks, what can be automated, and simply how to make our customer smile a little when they use our projects.
For that to work, apart from the [...]]]></description>
			<content:encoded><![CDATA[<p>One of the many things we debate constantly at Cognifide is how to improve the user experience. How to make editor’s life easier, how to simplify the common everyday tasks, what can be automated, and simply how to make our customer smile a little when they use our projects.</p>
<p>For that to work, apart from the overall big blocks to be in place and working seamlessly (which is the absolute minimum required) – you need to be VERY attentive to details. </p>
<p>What happens when user enters a place in the system where they are not usually required to work, are they properly guided? What do they see if they click on a little link somewhere in the corner? Does every image has an Alt text attached to it? Do your buttons have tooltips? Do the users have alternate views on all content? Do the system communicates abnormal states in a descriptive way and guides the user towards the solution? Is the UI logically laid out? Did you REALLY think what property should go on which tab? Have you setup the property names in a way that they make sense to non programmer? Do they have descriptions?</p>
<p>Part of the job we do is help sometimes troubled EPiServer customers get their solution built elsewhere or in-house to work, and I seem to be noticing some patterns which we have addressed in Cognifide as being bad practices. Many of those stem from the lack of research of the content served being done in the discovery phase. </p>
<h2>Discovery phase? What’s that?</h2>
<p>It seems that a great deal of projects does not seem to be well thought out in many aspects. When you look at the solution, It feels like a developer just got some templates and ran with them. Once the front end matches what the html templates outline, the solution is pushed to production and forgotten by the design/development agency and the poor customer is struggling with it for years trying to improve the ever degrading performance and fighting the CMS UI that’s been thrown together in a rush. Possibly aggravating in the process and rebuilding it again and again.</p>
<p>You need to realize that once your site goes to production, the trouble begins for your customer, not ends.</p>
<h2>Understand your content, please</h2>
<p>A very basic tendency for a lot of them is storing all the content of one type under a single tree node. or a very basic hierarchy. But:</p>
<ul>
<li>What is the volume of content in the start? </li>
<li>Have you talked to the client about the maintenance of the content? </li>
<li>How do they plan to store older content?
<ul>
<li>Are they archiving it? </li>
<li>Do they plan to serve it to general while archived? </li>
<li>Is the old content actively browsed on the CMS side? </li>
</ul>
</li>
<li>What is the volume increase over time? </li>
<li>What is the profile of the content? Is it a catalogue? Chronological news library? </li>
<li>Is there a taxonomy in place? </li>
<li>How often and which content is being modified? </li>
</ul>
<p>EPiServer shows pages in a tree, and while we have observed the CMS performance improving over time there are some basic scenarios that the hierarchy structure will never be able to deal with efficiently if not well thought out.</p>
<p>So your potential edge case scenarios might be that the customer has:</p>
<ol>
<li>10 000 articles that need to be migrated for the site to go live, but they only plan to add 2-3 a month, </li>
<li>They might be starting fresh but they plan to add 20 to 30 articles a day! </li>
</ol>
<p>How do you deal with those?</p>
<p>Obviously the worst thing you can do is to put them all under the “Articles” node. The customer will be frustrated to no end! Both you and the CMS reputation gets damaged while they try to do any basic thing in the CMS.</p>
<p>In the first case you need to work with the client to dissolve them into the hierarchy that’s granular enough to leave you with the 20-50 articles per node tops. Dividing it into 10 categories of roughly 1000 items won’t do! If the page names are meaningful, you may attempt to create a structure based on the first and second letter of the articles. This works best for directories of people or places.</p>
<p>The second case is probably going to happen to you when you will be working with any kind of news site, be that intranet of sorts or a news agency, TV portal or an information broker. In which case, it seems to be making the most sense to put the content into a chronological structure. Have a node for each year, month (and day if needed) there is an article. </p>
<h2>AUTOMATE! </h2>
<p>When a user writes an article that is supposed to fit into your content plan, move it into the proper node automatically. In the first case, move it to the proper category or based on the page title move it around to the proper place in the catalogue. In the chronological plan, move it to the day or month node upon creation. If a new node needs to be created for it – that’s your responsibility to do it. Organize the content for the user or you will be in a world of pain sooner than you expect!</p>
<p>Those tasks are easily automated by hooking into the page save and create events. Your customer will love you for it.</p>
<p>Naturally you don’t necessarily have to have a single plan on a given site. A site can have both branches with news-like plan and directory-like sub trees.</p>
<p>The base line is – you need to plan it ahead, and you need to learn about the content profile.</p>
<h2>Distinction <strong>with</strong> a difference</h2>
<p>You need to realize the distinction between the content and the presentation of it. Don’t try to cram the content into the browsing structure. Separation of concerns should not be limited to code organization. Separate concerns in the content structure as well.</p>
<p>Have the user trip designed around the best SEO practices. The hub pages should make sense from the visitor’s perspective. DON’T try to put your articles under it just because the hub page browses them. this may work for a little tiny sites but then again, those are not the sites that you will run into troubles because it basically means your customer is barely ever touching them.</p>
<p>Have your content stored in a separate branch and reach out for it with a tag set that is related to the hub page. </p>
<h2>Build a logical taxonomy and stick to it!</h2>
<p>That basically means – treat your content equally no matter where it’s stored – preferably having it tagged with a high performance framework like the <a href="http://blog.najmanowicz.com/category/software-development/episerver/faceted-navigation/">Faceted Navigation Framework</a> published by Cognifide some time ago or make it <a href="http://incubator.apache.org/lucene.net/">Lucene.Net</a> based. You can try to use the EPiServer built in categories. We have had limited success with it and the performance of FindPagesWithCriteria (which we have effectively banned from our arsenal) but I was told the performance in that front have improved greatly in the latest EPiServer CMS release.</p>
<p>Regardless – don’t rely on the page hierarchy structure to select the content, it doesn’t matter where it is, the metadata is what should be driving the content stream. You can hand pick your navigation links, fine, but article lists, news, announcements, events, treat it as a single content stream. Use a taxonomy to divide it into categories and you will be much happier in the long run as you will gain much more flexibility to reorganize the structure and move the content around when its profile changes later.</p>
<p>Using the EPiServer CMS for nearly 4 years now, those are the basic principles we have come to establish. </p>
<p>I wonder what are your practices? Where do you think our practices do or do not fit your design philosophy? Is there anything we could do better? Do you have practices regarding content planning? How do you analyze the content to make the best plan for it?</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=168&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2010/02/08/cms-ux-give-the-content-some-thought/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Easy Enum property for EPiServer</title>
		<link>http://blog.najmanowicz.com/2009/12/26/easy-enum-property-for-episerver/</link>
		<comments>http://blog.najmanowicz.com/2009/12/26/easy-enum-property-for-episerver/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 19:29:55 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Downloadable]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/?p=160</guid>
		<description><![CDATA[One of the most frequently and eagerly used programming constructs of the Microsoft.Net Framework is Enum. There are several interesting features that make it very compelling to use to for all kinds of dropdowns and checklists:

The bounds factor – proper use of Enum type guarantee that the selected value will fall within the constraints of [...]]]></description>
			<content:encoded><![CDATA[<p>One of the most frequently and eagerly used programming constructs of the Microsoft.Net Framework is Enum. There are several interesting features that make it very compelling to use to for all kinds of dropdowns and checklists:</p>
<ul>
<li>The bounds factor – proper use of Enum type guarantee that the selected value will fall within the constraints of the allowed value set.</li>
<li>The ability to treat Enums as flags (and compound them into flag sets) as well as a one-of selector. </li>
<li>The ease of use and potentially complete separation of the “Enum value” from the underlying machine type representation that ensures the most efficient memory usage. </li>
</ul>
<p>Surprisingly enough EPiServer as it stands right now does not have an easy facility to turn Enums into properties. To give credit where credit is due, the EPiServer framework provides a nice surrogate that mimic that behaviour to a degree. The relevant property types are:</p>
<ul>
<li><b><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_SpecializedProperties_PropertyAppSettingsMultiple.htm">PropertyAppSettingsMultiple</a></b>&#160; &#8211; which “creates check boxes with options that are defined in the AppSettings section in web.config. The name of the property should match the key for the app setting.” </li>
<li><b><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_SpecializedProperties_PropertyAppSettings.htm">PropertyAppSettings</a></b>&#160; &#8211; which “creates a drop down list with options that are defined in the AppSettings section in web.config. The name of the property should match the key for the app setting.”</li>
</ul>
<p>You quickly realize though that the properties have some limitations that makes their use a bit less compelling:</p>
<ul>
<li>The properties are not strongly typed </li>
<li>The property entry in AppSettings section has to have the name that matches the property name on the page. </li>
<li>It’s rather poorly documented, Other than relating to this blog entry or <a href="http://antecknat.se/blog/2008/04/18/new-appsettings-and-appsettingsmultiple-in-episerver-cms-5/">Erik’s post documenting</a> it I could not find any other examples on how to use them. (but then again, who needs docs really when we have <a href="http://reflector.red-gate.com/">Reflector</a>) </li>
<li>You cannot have the very same property duplicated on the page since you can only have a single property of a given name per page. So you need to have multiple entries in AppSettings that match the name of each of those properties on your pages. I know… semantics but still… </li>
<li>You are working on strings rather than enums (Did i mention it’s not type safe?) </li>
<li>The values in the AppSettings are stored in a somewhat DLS-y manner (consecutive options are separated from each other with the ‘|’ character, the name and the value are separated with a ‘;’, for example: &lt;add key = &quot;RegionId&quot; value=&quot;First Option;Option1|Default Option;Option2|Disabled Option;Option3&quot; /&gt; ) and I have had on an occasion entered a string there that caused the server to crash.</li>
<li>The values are not translatable, or at least I could not find how to do it and any Reflector digging rendered no results either. </li>
</ul>
<p> <span id="more-160"></span>
</p>
<h2>The solution to the problem:</h2>
<p>The solution that the blog post describes is:</p>
<ul>
<li>Type safe </li>
<li>Supports UI localization </li>
<li>Easy to use in your custom implementation </li>
<li>Flexible in allowing you to switch between the Enum being multi-choice or a single choice solution </li>
<li>fully defined in the code – no need to modify web,config. </li>
</ul>
<p>All you need to do to create your own custom Enum property is declare it.</p>
<pre style="background: white">
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
<span style="color: blue">using</span> Cognifide.EPiserverControls.EnumDropDown;

[<span style="color: #2b91af">PageDefinitionTypePlugIn</span>(DisplayName = <span style="color: #a31515">&quot;Sample Enum Property&quot;</span>)]
<span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #2b91af">SampleProperty</span> : <span style="color: #2b91af">PropertyEnumSelector</span>&lt;<span style="color: #2b91af">MySampleEnum</span>&gt;
{
}
</div>
</pre>
<p>That’s it, really!</p>
<p>Now if you want to customize it; obviously you need to provide the information for the property to work with. But let’s stop for a while and think, where does that information belong? </p>
<ul>
<li>The property should worry about the mechanics of editing and the tediousness of persistence of the edited value, it clearly is not the place to specify the link between the Enum type and its human friendly drop down text. </li>
<li>Web.config is for settings, not for describing content types and definitely not to enforce the property names. </li>
<li>So where should the metadata around your Enum type be? How about we put it around the Enum type itself?</li>
</ul>
<pre style="background: white">
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">[<span style="color: #2b91af">Flags</span>]
<span style="color: blue">public</span> <span style="color: blue">enum</span> <span style="color: #2b91af">MySampleEnum</span>
{
  [<span style="color: #2b91af">ValueVisualisation</span>(Name=<span style="color: #a31515">&quot;First Option&quot;</span>, LanguageKey=<span style="color: #a31515">&quot;/enum/first&quot;</span>)]
  Option1,</div>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
  [<span style="color: #2b91af">ValueVisualisation</span>(Name=<span style="color: #a31515">&quot;Default Option&quot;</span>, Selected=<span style="color: blue">true</span>, LanguageKey=<span style="color: #a31515">&quot;/enum/second&quot;</span>)]
  Option2,</div>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
  [<span style="color: #2b91af">ValueVisualisation</span>(Name=<span style="color: #a31515">&quot;Disabled Option&quot;</span>, Enabled=<span style="color: blue">false</span>, LanguageKey=<span style="color: #a31515">&quot;/enum/disabled&quot;</span>)]
  Option3,</div>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
  [<span style="color: #2b91af">ValueVisualisation</span>(Name=<span style="color: #a31515">&quot;Hidden Option&quot;</span>, Hide=<span style="color: blue">true</span>, LanguageKey=<span style="color: #a31515">&quot;/enum/hidden&quot;</span>)]
  Option4,</div>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
  [<span style="color: #2b91af">ValueVisualisation</span>(Name=<span style="color: #a31515">&quot;Fifth Option&quot;</span>, LanguageKey=<span style="color: #a31515">&quot;/enum/fifth&quot;</span>)]
  Option5,</div>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
}</div>
</pre>
<h2>What does all that do?</h2>
<p>The property using an Enum described this way will look the following way in EPiServer:</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/12/SampleEnumPropertyFlags.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SampleEnumPropertyFlags" border="0" alt="SampleEnumPropertyFlags" src="http://blog.najmanowicz.com/wp-content/uploads/2009/12/SampleEnumPropertyFlags_thumb.png" width="517" height="357" /></a></p>
<p>Let’s get into the what’s happened here as there’s more than catches the eye.</p>
<p>As you can see the enum values are named like they are in the attributes describing them, Default option is selected just like you could have expected by looking at the Selected=<span style="color: blue">true</span> in its attribute. The Enabled=<span style="color: blue">false</span> in the Disabled option results in an option that cannot be changed. The unchangeable option can be both unselected or selected by default. You may want to disable some deprecated options but still show them in the UI as a legacy but for some reason you might not want users to be able to change their value. Option4 is clearly missing, which is intended and specified by the Hide=<span style="color: blue">true</span>, as you might want to hide options that have been removed form the UI and on the same time you don’t want to loose compatibility with a legacy API that uses the option.</p>
<p>Also There is one thing about the first option on the list – <strong>it’s translated!</strong> The mechanism to specify the translation is based on the standard EPiServer localization files that you can find in the “lang” folder in your typical EPiServer installation. The Translation for the property looks like the following</p>
<pre style="background: white">
<div style="font-family: courier new; background: white; color: black; font-size: 8pt"><span style="color: blue">&lt;?</span><span style="color: #a31515">xml</span><span style="color: blue"> </span><span style="color: red">version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0</span>&quot;<span style="color: blue"> </span><span style="color: red">encoding</span><span style="color: blue">=</span>&quot;<span style="color: blue">utf-8</span>&quot;<span style="color: blue"> </span><span style="color: red">standalone</span><span style="color: blue">=</span>&quot;<span style="color: blue">yes</span>&quot;<span style="color: blue">?&gt;</span>
<span style="color: blue">&lt;</span><span style="color: #a31515">languages</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;</span><span style="color: #a31515">language</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">English</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">en</span>&quot;<span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">enum</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">first</span><span style="color: blue">&gt;</span>First Option Translated EN<span style="color: blue">&lt;/</span><span style="color: #a31515">first</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">enum</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;/</span><span style="color: #a31515">language</span><span style="color: blue">&gt;    </span>
<span style="color: blue">&lt;/</span><span style="color: #a31515">languages</span><span style="color: blue">&gt;</span></div>
</pre>
<p>so you see the value will take its translation key from the LanguageKey=<span style="color: #a31515">&quot;/enum/first&quot;</span>. </p>
<p>Ok, so we have the <b><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_SpecializedProperties_PropertyAppSettingsMultiple.htm">PropertyAppSettingsMultiple</a></b> replacement, but what about <b><a href="http://sdk.episerver.com/library/cms5/html/T_EPiServer_SpecializedProperties_PropertyAppSettings.htm">PropertyAppSettings</a></b>?</p>
<p>So here I reach the place where I am not 100% certain whether I took the proper path but I am sure I will hear about it if I didn’t :) The place where the property determines if it’s supposed to allow for multi selection or not is whether the Enum is marked with the [<span style="color: #2b91af">Flags</span>] attribute. Obviously Flags mean that the property is a form of a bit flag and should be able to allow the user to flip the bits independently rather than being the “one-of” type. So once you remove the [<span style="color: #2b91af">Flags</span>] form your enum you’re going to see it rendered the following way:</p>
<p><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/12/SampleEnumPropertyNoFlags.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="SampleEnumPropertyNoFlags" border="0" alt="SampleEnumPropertyNoFlags" src="http://blog.najmanowicz.com/wp-content/uploads/2009/12/SampleEnumPropertyNoFlags_thumb.png" width="517" height="357" /></a></p>
<p>But hey, it’s not a one way trip, if you decide that you want the enum rendered in another type of property and force the opposite behaviour you can always override it in the derived property like follows:</p>
<pre style="background: white">
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">    [<span style="color: #2b91af">PageDefinitionTypePlugIn</span>(DisplayName = <span style="color: #a31515">&quot;Sample Enum Property Checklist&quot;</span>)]
    <span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #2b91af">SamplePropertyChecklist</span> : <span style="color: #2b91af">PropertyEnumSelector</span>&lt;<span style="color: #2b91af">MySampleEnum</span>&gt;
    {
        <span style="color: blue">static</span> SamplePropertyChecklist()
        {
            MultiSelectEnum = <span style="color: blue">true</span>;
        }
    }</div>
</pre>
<p>so even if you think my usage of [<span style="color: #2b91af">Flags</span>] is faulty, the damage can be undone :)</p>
<p>Ok, but what about the enums that we have no control over – like enums form libraries. Obviously cannot retrofit attributes into them. Well, true but we still can have all of the control over the property.</p>
<p>Let’s assume for a moment that this is our legacy enum:</p>
<pre style="background: white">
<div style="font-family: courier new; background: white; color: black; font-size: 8pt"><span style="color: blue">public</span> <span style="color: blue">enum</span> <span style="color: #2b91af">MySampleLegacyEnum</span>
{
  Option1,
  Option2,
  Option3,
  Option4,
  Option5,
}</div>
</pre>
<p>You can just do nothing and simply use it in the property but the UI will display the not so nice Option1… names. That can be easily fixed – Again, specifying translation is the easiest way of achieving that goal. An xml for that enum would look like follows:</p>
<pre style="background: white">
<div style="font-family: courier new; background: white; color: black; font-size: 8pt"><span style="color: blue">&lt;?</span><span style="color: #a31515">xml</span><span style="color: blue"> </span><span style="color: red">version</span><span style="color: blue">=</span>&quot;<span style="color: blue">1.0</span>&quot;<span style="color: blue"> </span><span style="color: red">encoding</span><span style="color: blue">=</span>&quot;<span style="color: blue">utf-8</span>&quot;<span style="color: blue"> </span><span style="color: red">standalone</span><span style="color: blue">=</span>&quot;<span style="color: blue">yes</span>&quot;<span style="color: blue">?&gt;</span>
<span style="color: blue">&lt;</span><span style="color: #a31515">languages</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;</span><span style="color: #a31515">language</span><span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">English</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">en</span>&quot;<span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">MySampleLegacyEnum</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">Option1</span><span style="color: blue">&gt;</span>First Option<span style="color: blue">&lt;/</span><span style="color: #a31515">Option1</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">Option2</span><span style="color: blue">&gt;</span>Default Option<span style="color: blue">&lt;/</span><span style="color: #a31515">Option2</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">Option3</span><span style="color: blue">&gt;</span>Disabled Option<span style="color: blue">&lt;/</span><span style="color: #a31515">Option3</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">Option4</span><span style="color: blue">&gt;</span>Hidden Option<span style="color: blue">&lt;/</span><span style="color: #a31515">Option4</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">Option5</span><span style="color: blue">&gt;</span>Fifth Option<span style="color: blue">&lt;/</span><span style="color: #a31515">Option5</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">MySampleLegacyEnum</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;/</span><span style="color: #a31515">language</span><span style="color: blue">&gt;  </span>
<span style="color: blue">&lt;/</span><span style="color: #a31515">languages</span><span style="color: blue">&gt;</span></div>
</pre>
<p>The default values can be added by retrofitting the “DefaultValues” list with the elements that you want selected in the scenario where the property is first displayed for editing. You can also modify the inherited AvailableItems list to set the rest of the properties otherwise adjustable by the attributes. </p>
<p>Following is a sample of such retrofitted rules to match our original attribute-defined-enum.</p>
<pre style="background: white">
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">[<span style="color: #2b91af">PageDefinitionTypePlugIn</span>(DisplayName = <span style="color: #a31515">&quot;Sample Legacy Enum Property&quot;</span>)]
<span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #2b91af">SampleProperty</span> : <span style="color: #2b91af">PropertyEnumSelector</span>&lt;<span style="color: #2b91af">MySampleLegacyEnum</span>&gt;
{
    <span style="color: blue">static</span> SampleProperty()
    {
        MultiSelectEnum = <span style="color: blue">true</span>;

        <span style="color: green">// Make Option2 a default selected value</span>
        DefaultValues.Add(<span style="color: #2b91af">MySampleLegacyEnum</span>.Option2.ToString());
        AvailableItems.Where(p =&gt; p.Value == <span style="color: #2b91af">MySampleLegacyEnum</span>.Option2.ToString()).First().Selected = <span style="color: blue">true</span>;

        <span style="color: green">//Disable selection of Option3</span>
        AvailableItems.Where(p =&gt; p.Value == <span style="color: #2b91af">MySampleLegacyEnum</span>.Option3.ToString()).First().Enabled = <span style="color: blue">false</span>;

        <span style="color: green">//Remove hidden Option4</span>
        AvailableItems.RemoveAll(p =&gt; p.Value == <span style="color: #2b91af">MySampleLegacyEnum</span>.Option4.ToString());
    }
}</div>
</pre>
<p>The [<a href="http://www.najmanowicz.com/blog_bin/Cognifide.EPiserverControls.EnumDropDown.zip">code for the EnumProperty</a>] as well as [<a href="http://www.najmanowicz.com/blog_bin/Cognifide.EPiserverControls.EnumDropDown.Assembly.zip">the compiled binaries</a>] are available as Open Source and you can incorporate it in your projects as long as the Cognifide namespace is used for the code.</p>
<p>What do you think? Is that going to be useful for you?</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=160&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/12/26/easy-enum-property-for-episerver/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Database-based paged EPiServer searches for CMS 5 R2 SP2</title>
		<link>http://blog.najmanowicz.com/2009/07/07/database-based-paged-episerver-searches-for-cms-5-r2-sp2/</link>
		<comments>http://blog.najmanowicz.com/2009/07/07/database-based-paged-episerver-searches-for-cms-5-r2-sp2/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 11:15:25 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Microsoft SqlServer]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/07/07/database-based-paged-episerver-searches-for-cms-5-r2-sp2/</guid>
		<description><![CDATA[Aparently I have written something on that note before for CMS 4 and it looks like someone still needs it as I got a request for an updated version for it a couple of days ago. So here we go:
for the most part the syntax for the call is equivalent to what is was before [...]]]></description>
			<content:encoded><![CDATA[<p>Aparently I have written <a href="http://blog.najmanowicz.com/2007/05/21/database-based-paged-episerver-searches/">something on that note before for CMS 4</a> and it looks like someone still needs it as I got a request for an updated version for it a couple of days ago. So here we go:</p>
<p>for the most part the syntax for the call is equivalent to what is was before so go to my previous article regarding that (check out the old article for details). What I’ve added this time around is:</p>
<ul>
<li>the @PropertyName can be declared as ‘%’ if you want to look in all property names </li>
<li>@PropertyType can be –1 if you want to look in all property types otherwise you need to specify type id (this has changed from type name before due to database schema changes) </li>
<li>additionally this version of the stored proc will only look in the Master language Branch, so it will work for the single language pages and for multi-language but for language agnostic properties. (should you require the language to be variable the change is pretty simple – I can send you the updated version by email. </li>
</ul>
<pre class="brush: sql; highlight: [32];">/****** Object:  StoredProcedure [dbo].[PagedSearch]    Script Date: 07/07/2009 12:18:10 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PagedSearch]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[PagedSearch]
GO

CREATE Procedure PagedSearch
    @Condition varchar(1024),
    @PropertyName varchar(1024),
    @PropertyType int,
    @PageSize int,
    @PageNumber int,
    @Offset int
AS
BEGIN

    DECLARE @RowStart int
    DECLARE @RowEnd int

    SET @RowStart = @PageSize * @PageNumber + @Offset;
    SET @RowEnd = @RowStart + @PageSize + @Offset;

    WITH PageRefs AS
        (SELECT page.pkID as PageId,
            ROW_NUMBER() OVER (ORDER BY pageLang.StartPublish DESC) as RowNumber
            FROM tblPage page, tblProperty propValue, tblPageDefinition propDef, tblPageLanguage pageLang
            WHERE page.pkID = propValue.fkPageID
                AND page.fkMasterLanguageBranchID = pageLang.fkLanguageBranchID
                AND page.pkID = pageLang.fkPageID
                AND propValue.fkPageDefinitionID = propDef.pkID
                AND (@propertyType = -1 or propDef.fkPageDefinitionTypeID = @propertyType) -- is proper type
                AND propDef.Searchable = 1 -- the property is searchable
                AND propValue.String like @Condition -- contains facets
                AND propDef.[Name] like @PropertyName) -- property of proper name
    SELECT PageId
        FROM PageRefs
        WHERE (RowNumber Between @RowStart and @RowEnd) or (@PageSize = 0);
END
GO</pre>
<p>However&#8230; looking how the schema has changed over time, I am not convinced this approach is really the best one for someone who is not prepared to deal with the changes (e.g. you better be able to change the stored procedure based on the schema changes &#8211; or bribe me with pizza and beers for updates :) ).</p>
<p>Additionally this procedure only searches for properties that store their value in Short string field. To make it look into long string you need to Change the highlighted line to.</p>
<pre class="brush: sql;">AND (propValue.LongString like @Condition)</pre>
<p>or alternatively to look in both change it to:</p>
<pre class="brush: sql;">AND ((propValue.String like @Condition) or (propValue.LongString like @Condition))</pre>
<p>Enjoy!</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=143&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/07/07/database-based-paged-episerver-searches-for-cms-5-r2-sp2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SoakIE &#8211; a Web Server Stress Tool with a twist</title>
		<link>http://blog.najmanowicz.com/2009/05/10/soakie-a-web-server-stress-tool-with-a-twist/</link>
		<comments>http://blog.najmanowicz.com/2009/05/10/soakie-a-web-server-stress-tool-with-a-twist/#comments</comments>
		<pubDate>Sun, 10 May 2009 14:27:06 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Downloadable]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/05/10/soakie-a-web-server-stress-tool-with-a-twist/</guid>
		<description><![CDATA[Last week or so ago a couple of friends in another project in Cognifide has run into a wall while trying to load test their website. the problem was as follows: The website is highly AJAX based – the page merely loads a stub in the initial request but then loads the rest of its [...]]]></description>
			<content:encoded><![CDATA[<p>Last week or so ago a couple of friends in another project in Cognifide has run into a wall while trying to load test their website. the problem was as follows: The website is highly AJAX based – the page merely loads a stub in the initial request but then loads the rest of its data in a dynamic matter therefore a traditional web testing tools are fairly useless. What they tried was to setup a number of Selenium clients to pound the server, but that turned out to be fairly challenging to the machine doing the testing. It was not possible to set up more than 10 clients on a fairly strong machine.</p>
<p>Also there are other limitations like time to wait for the server to timeout and time between clicks, which I am not sure the tool allowed them to adjust. Talking to them I recalled <a href="http://blog.najmanowicz.com/2006/11/17/how-to-get-website-thumbnail-in-c/">a tool for grabbing website thumbnails</a> long time ago. one way for them would be to to make a batch file with it. The tool would grab the sites’ thumbnail and stress it, but they would still have to setup a number of clients. Also it creates and tears down an instance of IE every time, making it’s not optimal for that task.</p>
<p>So a couple of evenings later (and a few back-s and forth-s during the testing sessions) out comes SoakIE:</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/05/soakietest.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="SoakIETest" border="0" alt="SoakIETest" src="http://blog.najmanowicz.com/wp-content/uploads/2009/05/soakietest-thumb.png" width="429" height="387" /></a> </p>
<p> <span id="more-140"></span>
<p align="left">The app uses pretty much the same trick as the <a href="http://blog.najmanowicz.com/2006/11/17/how-to-get-website-thumbnail-in-c/">tool for grabbing website thumbnails</a> but it does so in a nice UI and allows for some rudimentary settings for profiling the traffic:</p>
<p><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/05/soakiesetup.png"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="SoakIESetup" border="0" alt="SoakIESetup" src="http://blog.najmanowicz.com/wp-content/uploads/2009/05/soakiesetup-thumb.png" width="429" height="387" /></a> </p>
<p>You can select the number of IE instances that will do the clicking, you can select a minimum time between clicks – that is how often any IE instance can click (if it already finished with the previous request). this allows you to simulate clients that will stay a minute on your site and only click after they’ve read the page. Additionally if your application can on an occasion encounter a deadlock or a hang, it allows you to specify the maximum time to live of each request. If the request takes longer than the specified time, the application will “Stop” the request.</p>
<p>One thing that we’ve noticed though is that after a long time of soak tests the IE instances get mighty fat and start to slow down dramatically. Therefore I’ve added a maximum number of clicks an IE instance can perform after which the client will no longer recycle it for more click but will tear it down and create a new IE instance to continue testing.</p>
<p>Naturally the application needs to know what to test. This is specified in the “Test setup&quot; tab in the “URLs to stress:&quot; text box. The URLs will be picked in a round-robin fashion. The first browser will get the first url, the next one will get the second and so on, if the list will get exhausted the browsers will get fed it from beginning. You can theoretically put them in the box with some other text (like pasting it from a Skype window without stripping the message decoration around them) – SoakIE should be smart enough to parse the text and get the URLs out of it.</p>
<p>You can download <a href="http://www.najmanowicz.com/blog_bin/SoakIE.zip">SoakIE here</a></p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=140&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/05/10/soakie-a-web-server-stress-tool-with-a-twist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced Language Manipulation Tool for EPiServer</title>
		<link>http://blog.najmanowicz.com/2009/04/06/advanced-language-manipulation-tool-for-episerver/</link>
		<comments>http://blog.najmanowicz.com/2009/04/06/advanced-language-manipulation-tool-for-episerver/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 15:49:11 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[Downloadable]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Microsoft SqlServer]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/04/06/advanced-language-manipulation-tool-for-episerver/</guid>
		<description><![CDATA[Have you ever (or have your customers) created and edited a page in one language only to realize that their selected locale was wrong? Have you ever wished you could delete a master language branch of a page&#160; after creating its localized counterpart but you could only delete the newly created slave language instead? Have [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever (or have your customers) created and edited a page in one language only to realize that their selected locale was wrong? Have you ever wished you could delete a master language branch of a page&#160; after creating its localized counterpart but you could only delete the newly created slave language instead? Have a customer ever requested that they could copy a whole branch and you convert it to another language so that they could then translate in-place?</p>
<p>Well I have… and I’m sure I will. And so did Fredrikj on the our #epicode IRC channel ;).</p>
<p>Basically I had the tool that would convert from one language to another, but Fredrikj requested something that would switch master language of a page from one to another. Since I’ve already had some of the work done, I’ve updated the stored procedure I’ve written some time ago and slapped a nice GUI up on it. Here’s the result:</p>
<p>&#160;</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/04/andvancedlanguagetool.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="AndvancedLanguageTool" border="0" alt="AndvancedLanguageTool" src="http://blog.najmanowicz.com/wp-content/uploads/2009/04/andvancedlanguagetool-thumb.png" width="480" height="484" /></a> </p>
<p>What the tool allows you to do is perform either language conversion or master branch switching on a selected page and all of its children (if you choose so).</p>
<p>The stored procedure have been updated to work on CMS5 R2 (will no longer work on R1 – but if you need that functionality, comment here or give me a shout and I’ll create a compatible version for you).</p>
<p>A word of caution though – I take no guarantee whatsoever about its operation. Especially, if you wreck your client’s database with it. I did what I could to prevent some of the obvious problems (like <strong><em>switching</em></strong> to a non existing master or <strong><em>converting</em></strong> to an existing one) but I will not be responsible if it won’t work for you. make a database backup and experiment there before you do any changes on the real data. That said – it works for me, so I think it should also work for you.</p>
<p>You can download the <a title="Episerver Advanced Language Tools" href="http://www.najmanowicz.com/blog_bin/EPiServerLanguageTools.zip" rel="enclosure">archive containing the tool here</a>. unzip it to your EPiServer web application folder keeping the folder structure or the plugin reference will be wrong. Include the *.aspx and the *.cs files in your project and apply the SQL file to your database (The manipulation is performed by a stored procedure located in the file).</p>
<p>Also if you’re performing the change in a load balanced environment, you may need to restart the other servers once you do the changes. I reset the DataFactory cache, but I am not sure it propagates through to other servers.</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=124&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/04/06/advanced-language-manipulation-tool-for-episerver/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Get out of my way! &#8230; or the story of file metadata for VirtualPathProvider in EPiServer</title>
		<link>http://blog.najmanowicz.com/2009/03/17/get-out-of-my-way-or-the-story-of-file-metadata-for-virtualpathprovider-in-episerver/</link>
		<comments>http://blog.najmanowicz.com/2009/03/17/get-out-of-my-way-or-the-story-of-file-metadata-for-virtualpathprovider-in-episerver/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 00:18:00 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/03/17/get-out-of-my-way-or-the-story-of-file-metadata-for-virtualpathprovider-in-episerver/</guid>
		<description><![CDATA[Immediately after you implement the VirtualPathProvider proxy from my previous post you will notice a one fairly serious lack in it. Namely all the files within that provider will be hiding behind the registration form. That is not cool for a couple of reasons…

You may want to keep all of the files in one store [...]]]></description>
			<content:encoded><![CDATA[<p>Immediately after you implement the VirtualPathProvider proxy from my previous post you will notice a one fairly serious lack in it. Namely all the files within that provider will be hiding behind the registration form. That is not cool for a couple of reasons…</p>
<ul>
<li>You may want to keep all of the files in one store – being forced to put them into a designated folder is not desired. </li>
<li>You may want to make some file freely available for some time and lock it after a while, or the other way around (e.g. to allow the robots to crawl it initially). having to move them is just silly and defeats the purpose. </li>
</ul>
<p>So how do you discriminate the files that you want locked from those that you want to be publically available, and potentially from those that you want only the logged in users to be able to get?</p>
<h2></h2>
<h2>Specifying the EPiServer File Metadata sweetness</h2>
<p>One of the potential solutions would be to define a special rights group and check for that group for the people that have your “registered” magic-cookie. That however introduces a bogus group, and I would rather like to avoid that. However if you look into the <strong><em>FileSummary.config</em></strong> file that’s located in your web application folder you will find a slightly mysterious content. A bit of hacking reveals that you can actually add your own metadata to the file. For example adding the access rights based on what I’ve established above would look as follows (the content you can already find in the file that comes with the public templates that-we-all-oh-so-love is skipped):</p>
<p><span id="more-120"></span></p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
<span style="color: blue">&lt;</span><span style="color: #a31515">root</span><span style="color: blue"> </span><span style="color: red">xmlns:xforms</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://www.w3.org/2002/xforms</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">      </span><span style="color: red">xmlns:xsi</span><span style="color: blue">=</span>&quot;<span style="color: blue">http://www.w3.org/2001/XMLSchema-instance</span>&quot;<span style="color: blue">&gt;</span>

<span style="color: blue">  &lt;</span><span style="color: #a31515">model</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">instance</span><span style="color: blue">&gt;</span>
      ...
<span style="color: blue">      &lt;</span><span style="color: #a31515">AccessLevel</span><span style="color: blue"> /&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">instance</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;/</span><span style="color: #a31515">model</span><span style="color: blue">&gt;</span>

  ...
<span style="color: blue">  &lt;</span><span style="color: #a31515">xforms:select1</span><span style="color: blue"> </span><span style="color: red">appearance</span><span style="color: blue">=</span>&quot;<span style="color: blue">full</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">                  </span><span style="color: red">ref</span><span style="color: blue">=</span>&quot;<span style="color: blue">AccessLevel</span>&quot;<span style="color: blue"> </span><span style="color: red">id</span><span style="color: blue">=</span>&quot;<span style="color: blue">id_field51</span>&quot;<span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>Unrestricted<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>Unrestricted<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>Requires Registration<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>RequireRegistration<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>Requires CMS Login<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:label</span><span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>LoggedUserAccess<span style="color: blue">&lt;/</span><span style="color: #a31515">xforms:value</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">xforms:item</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;/</span><span style="color: #a31515">xforms:select1</span><span style="color: blue">&gt;</span>
  ...

<span style="color: blue">&lt;/</span><span style="color: #a31515">root</span><span style="color: blue">&gt;</span></div>
</pre>
<p>Great. So what does it look in the file manager now?</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/03/metadataeditor.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="metadata-editor" border="0" alt="metadata-editor" src="http://blog.najmanowicz.com/wp-content/uploads/2009/03/metadataeditor-thumb.png" width="518" height="355" /></a> </p>
<p>Splendid!</p>
<h2>Accessing the metadata</h2>
<p>Now that we gave the user to specify the metadata, we need the VPP to act upon them. For the benefit of automation of parsing I’ve specified the enum defining the access levels as follows:</p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
<span style="color: blue">enum</span> <span style="color: #2b91af">FileAccessLevel</span>
{
    Unrestricted,
    RequireRegistration,
    LoggedUserAccess
}
</div>
</pre>
<p>Now we need to update the GetFile method to discriminate the access levels (I have decorated the core lines with <font color="#ff0000">&#8211;<strong>&gt;</strong></font>) those are the lines that access the meta data based on their format specified in the <strong><em>FileSummary.config</em></strong>.</p>
<pre class="brush: csharp; highlight: [11, 12, 13]">
public override VirtualFile GetFile(string virtualPath)
{
    string handledPath;

    if (TryGetHandledAbsolutePath(virtualPath, out handledPath))
    {
        UnifiedFile file = base.GetFile(virtualPath) as UnifiedFile;

        if (file != null)
        {
            string strAccessLevel = (string) file.Summary.Dictionary["AccessLevel"] ??
                                    FileAccessLevel.RequireRegistration.ToString();
            FileAccessLevel accessLevel = (FileAccessLevel) Enum.Parse(typeof (FileAccessLevel), strAccessLevel);

            bool isLoggedIn = HttpContext.Current.Profile != null &#038;&#038; !HttpContext.Current.Profile.IsAnonymous;
            bool isRegistered = HttpContext.Current.Request.Cookies.AllKeys.Contains(PASS_COOKIE_NAME);
            string email = isRegistered ? HttpContext.Current.Request.Cookies[PASS_COOKIE_NAME].Value :
                (isLoggedIn ? HttpContext.Current.Profile.UserName : "unregistered");

            switch (accessLevel)
            {
                case (FileAccessLevel.Unrestricted):
                    return file;
                    break;
                case(FileAccessLevel.RequireRegistration):
                    if (!isRegistered &#038;&#038; ! isLoggedIn)
                    {
                        HttpContext.Current.Response.Redirect(
                            string.Format(registrationFormUrl,
                                          HttpContext.Current.Server.HtmlEncode(virtualPath)));
                        return null;
                    }
                    return file;
                    break;
                case(FileAccessLevel.LoggedUserAccess):
                    if (isLoggedIn)
                    {
                        return file;
                    }
                    return null;
                    break;
                default:
                    return file;
            }
        }
    }
    return Previous.GetFile(virtualPath);
}
</pre>
<p>Now the user is really in control of what is published to the general public and robots, what is protected with the registration form and what is only available to logged in users. (now you may add more granularity with file rights naturally, this is just a basic setting that an editor without administrative rights can add.</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=120&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/03/17/get-out-of-my-way-or-the-story-of-file-metadata-for-virtualpathprovider-in-episerver/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple registration for files served by EPiServer</title>
		<link>http://blog.najmanowicz.com/2009/03/12/simple-registration-for-files-served-by-episerver/</link>
		<comments>http://blog.najmanowicz.com/2009/03/12/simple-registration-for-files-served-by-episerver/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 21:01:00 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Solution]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/03/12/simple-registration-for-files-served-by-episerver/</guid>
		<description><![CDATA[With the culture of knowledge sharing and open source spreading, everyone races to show they have something valuable that you may want. And while you may not ask for money for your content you may still want to get something in return, say a contact, an email address that’s verified (or not), to keep in [...]]]></description>
			<content:encoded><![CDATA[<p>With the culture of knowledge sharing and open source spreading, everyone races to show they have something valuable that you may want. And while you may not ask for money for your content you may still want to get something in return, say a contact, an email address that’s verified (or not), to keep in touch with the consumer of your content. </p>
<p>Yet a full fledged registration doesn’t seem like a proper thing to do – cluttering your EPiServer user repository with (let’s face it – for a large part fake or temporary email addresses that user create only to get your content).</p>
<p>While there may be a lot of ways to handle that (streaming it through a page Response.WriteFile might seem as one of the more obvious ones), I would like to show you a cleaner, simpler and more elegant way that I’ve come up with.</p>
<p>We really don’t want people to deep link to our files without them knowing the files are from our site, that’s just rude – so hiding them behind an obscure URL wouldn’t work (thus we cannot use the regular file providers). We’ve already establish that we don’t want to log them in, so setting file rights are useless. But I want all the benefits including client-side caching.</p>
<p>Basically the solution boils down to creating a thin layer over the File provider of our choice, in my case the versioning file provider. The only method we need to override in it is <strong>GetFile</strong>. I want to allow downloading for logged in users and I want to allow downloading for all users that have a “magic-cookie” set. If either of the conditions are met, the file just downloads using the underlying provider’s routines including all the logic EPiServer has put for caching and rights. But if neither of the requirements are met, the user is directed to a page of our choice. </p>
<p><span id="more-117"></span></p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt"><span style="color: blue">public</span> <span style="color: blue">override</span> <span style="color: #2b91af">VirtualFile</span> GetFile(<span style="color: blue">string</span> virtualPath)
{
    <span style="color: blue">string</span> handledPath;

    <span style="color: blue">if</span> (TryGetHandledAbsolutePath(virtualPath, <span style="color: blue">out</span> handledPath))
    {
        <span style="color: blue">if</span> ((<span style="color: #2b91af">HttpContext</span>.Current.Profile != <span style="color: blue">null</span> &amp;&amp; !<span style="color: #2b91af">HttpContext</span>.Current.Profile.IsAnonymous) ||
            <span style="color: #2b91af">HttpContext</span>.Current.Request.Cookies.AllKeys.Contains(PASS_COOKIE_NAME))
        {
            <span style="color: blue">return</span> <span style="color: blue">base</span>.GetFile(virtualPath);
        }

        <span style="color: #2b91af">HttpContext</span>.Current.Response.Redirect(
            <span style="color: blue">string</span>.Format(registrationFormUrl,<span style="color: #2b91af">HttpContext</span>.Current.Server.HtmlEncode(virtualPath)));
        <span style="color: blue">return</span> <span style="color: blue">null</span>;
    }
    <span style="color: blue">return</span> Previous.GetFile(virtualPath);
}</div>
</pre>
<p>How you specify that page’s totally up to you, but there is a nice initialization routine called during the Virtual Path Provider loading phase where all of the settings that are specified in your relevant web.config VPP declaration are passed to you, why not use it? What you’ll need define your VPP in the web.config is what follows:</p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
<span style="color: blue">&lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">showInFileManager</span><span style="color: blue">=</span>&quot;<span style="color: blue">true</span>&quot;<span style="color: blue"> </span><span style="color: red">virtualName</span><span style="color: blue">=</span>&quot;<span style="color: blue">CookieEnabled</span>&quot;<span style="color: blue"> </span><span style="color: red">virtualPath</span><span style="color: blue">=</span>&quot;<span style="color: blue">~/CookieEnabled/</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">     </span><span style="color: red">bypassAccessCheck</span><span style="color: blue">=</span>&quot;<span style="color: blue">false</span>&quot;<span style="color: blue"> </span><span style="color: red">name</span><span style="color: blue">=</span>&quot;<span style="color: blue">CookieEnabled</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">     </span><span style="color: red">type</span><span style="color: blue">=</span>&quot;<span style="color: blue">Cognifide.EPiServer.CookieEnabledVirtualPathProvider.CookieEnabledVirtualPathProvider,Cognifide.EPiServer.CookieEnabledVirtualPathProvider</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">     </span><span style="color: red">indexingServiceCatalog</span><span style="color: blue">=</span>&quot;<span style="color: blue">Web</span>&quot;<span style="color: blue"> </span><span style="color: red">physicalPath</span><span style="color: blue">=</span>&quot;<span style="color: blue">C:\vpp\Resources</span>&quot;<span style="color: blue"> </span>
<span style="color: blue">     </span><span style="color: red">RegistrationFormUrl</span><span style="color: blue">=</span>&quot;<span style="color: blue">/File-Asset-Request-Form/?filepath={0}</span>&quot;<span style="color: blue"> /&gt;</span>
</div>
</pre>
<p>
  <br />you can then define your class as:</p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
<span style="color: blue">public</span> <span style="color: blue">class</span> <span style="color: #2b91af">CookieEnabledVirtualPathProvider</span> : <span style="color: #2b91af">VirtualPathVersioningProvider</span>
{
    <span style="color: blue">private</span> <span style="color: blue">const</span> <span style="color: blue">string</span> REGISTRATION_FORM_URL_WEB_CONFIG_PARAM_NAME = <span style="color: #a31515">&quot;RegistrationFormUrl&quot;</span>;
    <span style="color: blue">public</span> <span style="color: blue">const</span> <span style="color: blue">string</span> PASS_COOKIE_NAME = <span style="color: #a31515">&quot;ResourcePass&quot;</span>;
    <span style="color: blue">private</span> <span style="color: blue">string</span> registrationFormUrl;

    <span style="color: blue">public</span> CookieEnabledVirtualPathProvider(<span style="color: blue">string</span> name, <span style="color: #2b91af">NameValueCollection</span> configParameters) :
        <span style="color: blue">base</span>(name, configParameters)
    {
        registrationFormUrl = configParameters[REGISTRATION_FORM_URL_WEB_CONFIG_PARAM_NAME];
    }

    ...

}
</div>
</pre>
<p>So we know now where we want to direct people without a “magic-cookie” who want to get our assets, and how to do it, but how do we finally allow that file to get down to them?</p>
<p>In your page – for the same of simplicity I assume you will be using XForms for gathering the user data, but that really does not matter. When you validate the form data (or get the user to click on a link that you’ve sent them) you just set the “magic” cookie that I called “ResourcePass” to any value and to to expire in some a long amount of time, like a year. So that they can now access your files unrestrained and direct them BACK at the URL they came from – and now the VPP will allow them to just download the file they initially requested:</p>
<pre>
<div style="font-family: courier new; background: white; color: black; font-size: 8pt">
<span style="color: blue">protected</span> <span style="color: blue">void</span> XForm_BeforeSubmitPostedData(<span style="color: blue">object</span> sender, <span style="color: #2b91af">SaveFormDataEventArgs</span> e)
{
    <span style="color: blue">if</span> (!Page.IsValid)
    {
        e.CancelSubmit = <span style="color: blue">true</span>;
    }
    <span style="color: blue">else</span>
    {
        <span style="color: blue">string</span> requestedFile = Request.Params[<span style="color: #a31515">&quot;filepath&quot;</span>];
        <span style="color: #2b91af">HttpCookie</span> cookie = <span style="color: blue">new</span> <span style="color: #2b91af">HttpCookie</span>(<span style="color: #2b91af">CookieEnabledVirtualPathProvider</span>.PASS_COOKIE_NAME, <span style="color: #a31515">&quot;true&quot;</span>);
        cookie.Expires = <span style="color: #2b91af">DateTime</span>.Now.AddYears(1);
        cookie.HttpOnly = <span style="color: blue">true</span>;
        Response.Cookies.Add(cookie);
        <span style="color: blue">if</span> (!<span style="color: blue">string</span>.IsNullOrEmpty(requestedFile))
        {
            Response.Redirect(requestedFile);
        }
    }
}
</div>
</pre>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=117&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/03/12/simple-registration-for-files-served-by-episerver/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>WebParts based Sidebar for EPiServer &#8211; how to use it?</title>
		<link>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-how-to-use-it/</link>
		<comments>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-how-to-use-it/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 17:06:47 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Downloadable]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web applications]]></category>
		<category><![CDATA[WebParts]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-how-to-use-it/</guid>
		<description><![CDATA[Once you’ll update the framework to the extended one, you will immediately notice that… nothing has changed. Hmm… did something go wrong? 
Well, not really. By default the framework will be run in the “legacy mode”. Thanks to an old article by our own Marek Blotny, I’ve learned how to build Plugin settings which are [...]]]></description>
			<content:encoded><![CDATA[<p>Once you’ll update the framework to the extended one, you will immediately notice that… nothing has changed. Hmm… did something go wrong? </p>
<p>Well, not really. By default the framework will be run in the “legacy mode”. Thanks to <a href="http://marekblotny.blogspot.com/2008/07/plugins-and-datafactory-event-handlers.html">an old article by our own Marek Blotny</a>, I’ve learned how to build Plugin settings which are just perfect for the purpose!</p>
<p align="left">So to configure and enable the new features you need to open your admin UI and in the “Config” click on the “Plugin Manager” item and select our framework plugin as shown in the picture</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings1.png"><img title="WebPartFrameworkPluginSettings1" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="164" alt="WebPartFrameworkPluginSettings1" src="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings1-thumb.png" width="244" border="0" /></a></p>
<p>The available options are:</p>
<p><span id="more-110"></span><br />
<table cellspacing="0" cellpadding="2" border="0">
<tbody>
<tr>
<td><b>Setting Name</b></td>
<td><b>Meaning</b></td>
<td><b>Sample</b></td>
</tr>
<tr>
<td><b><i>Default WebParts Path Pattern</i></b></td>
<td>The pattern to be used when no pattern is defined for a page.</td>
<td>%inherit%</td>
</tr>
<tr>
<td><b><i>WebParts Path Patterns</i></b></td>
<td>The semicolon separated pairs of pattern;pattern name;          <br />This is the part you will want to customize most.</td>
<td>%template%|%pageid%%legacyregion%;Legacy regionalized;%template%|%pageid%;Legacy globalized;page|%pageid%|%region%;Page/region;pagetype|%pagetypeid%;Page Type</td>
</tr>
<tr>
<td><b><i>Cache WebParts in Memory</i></b></td>
<td>Determines whether the WebParts are to be cached&#160; between usages (this is useful for a small set of WebParts (like a number of sidebars) but rather discouraged if you use the legacy mode as there can be a lot of those in such case.</td>
<td>unchecked by default (check to improve performance in sidebar mode)</td>
</tr>
<tr>
<td><b><i>Legacy WebParts Support (per-page only)</i></b></td>
<td>If checked, disables the extensions described by this blog.</td>
<td>checked by default (uncheck to enable the sidebar extensions)</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>As shown here:</p>
<p><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings2.png"><img title="WebPartFrameworkPluginSettings2" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="179" alt="WebPartFrameworkPluginSettings2" src="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings2-thumb.png" width="244" border="0" /></a> </p>
<p>&#160;</p>
<p>Once you fill in the settings as they are suggested in the above table the context menu (or adjust to your needs) will show you the new options:</p>
<p align="center"><a href="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings3.png"><img title="WebPartFrameworkPluginSettings3" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="173" alt="WebPartFrameworkPluginSettings3" src="http://blog.najmanowicz.com/wp-content/uploads/2009/01/webpartframeworkpluginsettings3-thumb.png" width="244" border="0" /></a> </p>
</p>
<p>The new sub menu will allow you to change the pattern by which the WebParts are selected, while “Edit Web Parts” option will enable you to edit the WebParts for the current effective WebPart set.</p>
<p><font color="#ff0000"><strong>First of all – if you want to select a pattern on a page you need a means of storing it. At this moment The framework does it in a property. Which means &#8211; for every page type that wants to redefine the web parts rather than using the default pattern (in our case %inherited%) you need to add String property with a “WebPartsPath” name (I may actually add some routines to add the property definition automatically if there will be enough demand for that).</strong></font></p>
<h1>What does “Effective WebPart Set” mean?</h1>
<p>Assuming (which is the most interesting scenario) that %inherit% is the default pattern the following is true: </p>
<p>&#160;</p>
<table border="1">
<tbody>
<tr>
<td><b>Page</b></td>
<td><b>WebPartsPath</b></td>
<td><b>Effective path</b></td>
<td><b>Description</b></td>
</tr>
<tr>
<td>Start</td>
<td>&#160;</td>
<td>%root%</td>
<td>Since it&#8217;s a start page and it does not define path %root% is used.</td>
</tr>
<tr>
<td>+ News</td>
<td>&#160;</td>
<td>%root%</td>
<td>inherits from start page which does not define path but inherits from %root%.</td>
</tr>
<tr>
<td>+ Events</td>
<td>page|%pageid%</td>
<td>page|5</td>
<td>directly implements its own pattern.</td>
</tr>
<tr>
<td>| + Partner Day</td>
<td>%inherit%</td>
<td>page|5</td>
<td>Inherits after its parent page.</td>
</tr>
<tr>
<td>+ International</td>
<td>page|%pageid%|%region%</td>
<td>page|6|en, page|6|se</td>
<td>Defines separate WebParts for every language that the page is created for.</td>
</tr>
<tr>
<td>| + Sweden</td>
<td>%inherit%</td>
<td>page|6|se</td>
<td>Inherits after its parent page in its own language.</td>
</tr>
<tr>
<td>| + England</td>
<td>%inherit%</td>
<td>page|6|en</td>
<td>Inherits after its parent page in its own language.</td>
</tr>
</tbody>
</table>
<p>Once you select the effective web parts for the page or just agree with the WebParts pre-selected for you based on the default path you can edit them just like previously. Mind that when you edit WebParts on a page all the pages that have the same “effective path” are going to change as well. (which was our intention in the first place).</p>
<p>&#160;</p>
<p>The library extension is going to be posted on Epicode as soon as I get a hold of Steve to approve the changes :)</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=110&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-how-to-use-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WebParts based Sidebar for EPiServer &#8211; the motivation and specification</title>
		<link>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-the-motivation-and-specification/</link>
		<comments>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-the-motivation-and-specification/#comments</comments>
		<pubDate>Thu, 08 Jan 2009 14:04:12 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Downloadable]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web applications]]></category>
		<category><![CDATA[WebParts]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-the-motivation-and-specification/</guid>
		<description><![CDATA[Back in the day when we started designing our last project we’ve been presented with a following problem – a big number of templates with slightly different sidebars.
Hmm… 
Is sidebar a part of content? No, rather not. We don’t want the editors to have to setup the sidebar for every article they write (and the [...]]]></description>
			<content:encoded><![CDATA[<p>Back in the day when we started designing our last project we’ve been presented with a following problem – a big number of templates with slightly different sidebars.</p>
<p>Hmm… </p>
<p>Is sidebar a part of content? No, rather not. We don’t want the editors to have to setup the sidebar for every article they write (and the site has a few dozens of articles created on it every day).</p>
<p>Is sidebar more of a template thing? Well… more like it, but still… we have articles all over the site with different sidebar elements when the articles are in different parts of the site (ok so we could add rules what controls display in which part of the site). <strong>But wait! There’s more!</strong> The sidebar will be different for every language (region). Now we’re talking a dozen of templates or a rules engine just to make the sidebar different. Customising the template with properties isn’t ideal either as it makes EPiServer UI very cluttered. Additionally we want to change sidebars across many templates so the whole branch/section of the site will be able to share the same sidebar.</p>
<p>To a degree this is an academic discussion as we’ve been through it with the previous version of the site and we already knew that integrating this stuff into templates just won’t work and we will be in a world of pain just changing the templates over and over adding little tweaks and changes while the customer ads promotions and performs ad campaigns. Well, we can do it, of course, but it’s not a work a programmer will enjoy, and we all want to do new and more exciting things, don’t we?</p>
<p>We have an internally developed&#160; module to make something like that, that is fully home-grown by another internal team (we now have 3 “squads” capable or making incredible things with EPiServer and we tend to share a lot of technologies and try to rotate people around to adopt the good habits and experiences) and I was (and still am) VERY impressed by it. The technology uses EPiServer pages for defining every module (which are located somewhere outside the site root branch. and then you can mix and match them either declaratively in the code) or by handpicking them in the UI. It’s really cool, though, during the discussions it turned out that we might have to add big chunks of functionality and might end up with separate branches of module-pages for different languages/regions, but… frankly… about that time <a href="http://labs.episerver.com/en/Blogs/Ted-Nyberg/Dates/112276/8/Using-web-parts-in-EPiServer/">an article by Ted Nyberg</a> reminded me about a technology I have read about quite a while ago in <a href="http://labs.episerver.com/en/Blogs/Stein-Viggo-Grenersen/Dates/112262/2/EPiServer-on-steroids/">an article by Stein-Viggo Grenersen</a> and ooohhhhhh… I got seduced. I really wanted to try if for a long time and Ted’s article made it a snap to try and get convinced, and more important… convince Stu ;) that it’s the right way to explore.</p>
<h2>So I started to dig.</h2>
<p><span id="more-103"></span></p>
<h2></h2>
<p><a href="http://labs.episerver.com/en/Blogs/Stein-Viggo-Grenersen/Dates/112262/2/EPiServer-on-steroids/"><img style="display: inline; margin: 0px 10px 0px 0px" src="http://www.najmanowicz.com/blog_images/DragDropWebPartsmaller.gif" align="left" /></a>Talked with <a href="http://stevecelius.spaces.live.com/">Steve</a> (the original creator of the Framework) a bit and learned that I can “customize a path rewriter” to suit my needs. Great! I just hoped I won’t have to deal with some nasty GUID’s matching, but no! Turns out, all it takes to identify a WebPart set is to have any unique string naming it.</p>
<p>So basically what we needed was a manager to deal with the naming templates and a way to determine the WebParts set to be used per page.</p>
<p>Till now the framework used template file name followed by the page ID, followed by an eventual language/region if a page was not the master branch, for example:</p>
<blockquote><p>~/templates/Demo/WebPartPage.aspx|26    <br />~/templates/Demo/WebPartPage.aspx|26|en-us </p></blockquote>
<p>which makes them unique per page, which is not as appealing when you use EPiServer as it for a big part duplicates its functionality. Also a bit of a caveat here for agile programming methodology which promotes an often and early refactoring – if you move your page around or change its name – you lose the WebParts for all pages using it.</p>
<p>What we needed is a flexible and extensible scheme for reusing “WebParts sets” and that’s what our extension allows for.</p>
<p>Also since we’re very performance sensitive, and we operate in a multi server scenarios a lot we’ve added web parts blobs caching. Meaning that the site does not have to reach to the database every time a page is rendered.</p>
<p>The very appealing side of the framework is that it can be extended form the bottom (persistence) from the top (editors, controls, webparts), as well as being pluggable with custom plumbing.</p>
<h2>The Sidebar Extensions for WebParts Framework</h2>
<p>So to put all the requirements together, we needed the sidebars to be:</p>
<ul>
<li>customizable (out of the box) </li>
<li>easy to use for both developers and editors (out of the box) Wow Steve, I can’t really appreciate enough how cool it is to code for it and how nice it is for the users! </li>
<li>localizable </li>
<li>reusable </li>
<li>inheritable for site branches </li>
</ul>
<h2>WebParts path patterns</h2>
<p>The main idea was to free the path names from the restriction they had – being hardcoded for a page. So to do it without hard-coding them I’ve introduced path patterns. </p>
<h3>What is a pattern?</h3>
<p>Basically a pattern is a way the framework is supposed to encode the WebParts&#160; id for the system to identify. Your site can have any number of “named patterns” and the framework gives you means of switching between them. Pattern allow for almost any string to be a part of it although some tokens have special meaning:</p>
<table cellspacing="0" cellpadding="2" width="680" border="0">
<tbody>
<tr>
<td valign="top" width="200"><strong>Token</strong></td>
<td valign="top" width="478"><strong>Replacemnt Value</strong></td>
</tr>
<tr>
<td valign="top" width="200">%pageid%</td>
<td valign="top" width="478">id of the page the path is formed for</td>
</tr>
<tr>
<td valign="top" width="200">%region%</td>
<td valign="top" width="478">language/region of the WebParts</td>
</tr>
<tr>
<td valign="top" width="200">%pagetypeid%</td>
<td valign="top" width="478">type of the page</td>
</tr>
<tr>
<td valign="top" width="200">%template%</td>
<td valign="top" width="478">legacy token to make it possible to use template names as part of path.          <br />This is just for compatibility so you can have some of the pages using an old scheme.</td>
</tr>
<tr>
<td valign="top" width="200">%legacyregion%</td>
<td valign="top" width="478">legacy token for regionalizable pages (usage described later)</td>
</tr>
<tr>
<td valign="top" width="200">%inherited%</td>
<td valign="top" width="478">states that a page shoud inherit its WebParts from its parent in the page hierarchy (this can only be used as a complete pattern – cannot be a part of a larger pattern)</td>
</tr>
<tr>
<td valign="top" width="200">%root%</td>
<td valign="top" width="478">(again whole pattern) the %root% token is used when the inheritance based on hierarchy does not resolve into another token while reaching the root page.</td>
</tr>
</tbody>
</table>
<h3>Some sample patterns</h3>
<table cellspacing="0" cellpadding="2" width="600" border="1">
<tbody>
<tr>
<td valign="top" width="100"><strong>Name</strong></td>
<td valign="top" width="100"><strong>Pattern</strong></td>
<td valign="top" width="150"><strong>Sample Instance</strong> <strong>of the Pattern</strong></td>
<td valign="top" width="200"><strong>Description</strong></td>
</tr>
<tr>
<td valign="top" width="100">Root pattern</td>
<td valign="top" width="100">%root%</td>
<td valign="top" width="150">%root%</td>
<td valign="top" width="200">The pattern that all inheritance automatically falls back to</td>
</tr>
<tr>
<td valign="top" width="100">Inherited</td>
<td valign="top" width="100">%inherit%</td>
<td valign="top" width="150">anything parent defines</td>
<td valign="top" width="200">Tells the page to use the web parts its parent is using – the inheritance is possible all the way up in the hierarchy to the %root% pattern, meaning – if my parent inherits its WebParts from its parent, so will I.</td>
</tr>
<tr>
<td valign="top" width="100">Legacy regionalized</td>
<td valign="top" width="100">%template%|%pageid%%legacyregion%</td>
<td valign="top" width="150">~/templates/Demo/​​WebPartPage.aspx|26|en-us</td>
<td valign="top" width="200">Creates legacy “non language independent path”</td>
</tr>
<tr>
<td valign="top" width="100">Legacy global </td>
<td valign="top" width="100">%template%|%pageid%</td>
<td valign="top" width="150">~/templates/Demo/​​WebPartPage.aspx|26</td>
<td valign="top" width="200">Creates legacy “language independent path”</td>
</tr>
<tr>
<td valign="top" width="100">Page/region specific</td>
<td valign="top" width="100">page|%pageid%|%region%</td>
<td valign="top" width="150">page|26|en-us</td>
<td valign="top" width="200">template independent per-page/per-language pattern</td>
</tr>
<tr>
<td valign="top" width="100">PageType specific</td>
<td valign="top" width="100">pagetype|%pagetypeid%</td>
<td valign="top" width="150">pagetype|5</td>
<td valign="top" width="200">page type specific path (notice how the previous pattern has “page” and this one has “pagetype” in it) – this is done to avoid conflicts in numbers between pages and page types of the same id</td>
</tr>
<tr>
<td valign="top" width="100">My Sidebar</td>
<td valign="top" width="100">my-sidebar</td>
<td valign="top" width="150">my-sidebar</td>
<td valign="top" width="200">You can create “named sets” that will stay the same across all pages using it</td>
</tr>
<tr>
<td valign="top" width="100">My Localizable Sidebar</td>
<td valign="top" width="100">my-sidebar|%region%</td>
<td valign="top" width="150">my-sidebar|en-us</td>
<td valign="top" width="200">A localized version of the previous “named set”</td>
</tr>
</tbody>
</table>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=103&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2009/01/08/webparts-based-sidebar-for-episerver-the-motivation-and-specification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fix for EPiServer CMS5 interfering with your EPiServer 4</title>
		<link>http://blog.najmanowicz.com/2008/06/27/fix-for-episerver-cms5-interfering-with-your-episerver-4/</link>
		<comments>http://blog.najmanowicz.com/2008/06/27/fix-for-episerver-cms5-interfering-with-your-episerver-4/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 14:47:11 +0000</pubDate>
		<dc:creator>Adam Najmanowicz</dc:creator>
				<category><![CDATA[.Net Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[EPiCode]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Web applications]]></category>

		<guid isPermaLink="false">http://blog.najmanowicz.com/2008/06/27/fix-for-episerver-cms5-interfering-with-your-episerver-4/</guid>
		<description><![CDATA[
The problem that can make a grown up man cry… 
You’re editing your EPiServer 4 project and suddenly the edit mode stops working. the server reports compilation errors. something along the lines:
Compiler error: CS0433: Type „EPiServer.Global” exists in „c:\WINDOWS\assembly\GAC_MSIL\EPiServer\5.1.422.122__8fe83dea738b45b7\EPiServer.dll” and „c:\WINDOWS\assembly\GAC\EPiServer\4.61.5.83__8fe83dea738b45b7\EPiServer.dll”

The solution is to go to your web.config and edit the compilation section. The section [...]]]></description>
			<content:encoded><![CDATA[</p>
<p>The problem that can make a grown up man cry… </p>
<p>You’re editing your EPiServer 4 project and suddenly the edit mode stops working. the server reports compilation errors. something along the lines:</p>
<blockquote><p>Compiler error: CS0433: Type „EPiServer.Global” exists in „c:\WINDOWS\assembly\GAC_MSIL\EPiServer\5.1.422.122__8fe83dea738b45b7\EPiServer.dll” and „c:\WINDOWS\assembly\GAC\EPiServer\4.61.5.83__8fe83dea738b45b7\EPiServer.dll”</p>
</blockquote>
<p>The solution is to go to your web.config and edit the compilation section. The section will most probably look something like this:</p>
<pre>
<div style="font-size: 8pt; background: white; color: black; font-family: courier new"><span style="color: blue">&lt;</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">compilation</span><span style="color: blue"> </span><span style="color: red">defaultLanguage</span><span style="color: blue">=</span>&quot;<span style="color: blue">c#</span>&quot;<span style="color: blue"> </span><span style="color: red">debug</span><span style="color: blue">=</span>&quot;<span style="color: blue">true</span>&quot;<span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">assemblies</span><span style="color: blue">&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">EPiServer, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">EPiServer.BaseLibrary, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">System.Configuration.Install, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">EPiServer.Configuration, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">EPiServer.Implementation, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">EPiServer.XForms, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">EPiServer.Events, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">EPiServer.Lucene, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">ElektroPost.Licensing, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">EPiServer.Wsrp, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">EPiServer.WebParts, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">EPiServer.UI, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">EPiServer.Web.WebControls, Version=5.1.422.122, Culture=neutral, PublicKeyToken=8FE83DEA738B45B7</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">      &lt;/</span><span style="color: #a31515">assemblies</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">compilation</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;/</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;                  </span>
<span style="color: blue">&lt;/</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;    </span>
</div>
</pre>
<p>in my case only the 4th line referencing the EPiServer.dll was interfering with the editing working, but this can easily be trimmed to only first 3 options, so once you&#8217;re done with removing CMS5 entries it could look something like:</p>
<pre>
<div style="font-size: 8pt; background: white; color: black; font-family: courier new"><span style="color: blue">&lt;</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;</span><span style="color: #a31515">compilation</span><span style="color: blue"> </span><span style="color: red">defaultLanguage</span><span style="color: blue">=</span>&quot;<span style="color: blue">c#</span>&quot;<span style="color: blue"> </span><span style="color: red">debug</span><span style="color: blue">=</span>&quot;<span style="color: blue">true</span>&quot;<span style="color: blue">&gt;</span>
<span style="color: blue">      &lt;</span><span style="color: #a31515">assemblies</span><span style="color: blue">&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">        &lt;</span><span style="color: #a31515">add</span><span style="color: blue"> </span><span style="color: red">assembly</span><span style="color: blue">=</span>&quot;<span style="color: blue">System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35</span>&quot;<span style="color: blue">/&gt;</span>
<span style="color: blue">      &lt;/</span><span style="color: #a31515">assemblies</span><span style="color: blue">&gt;</span>
<span style="color: blue">    &lt;/</span><span style="color: #a31515">compilation</span><span style="color: blue">&gt;</span>
<span style="color: blue">  &lt;/</span><span style="color: #a31515">system.web</span><span style="color: blue">&gt;                  </span>
<span style="color: blue">&lt;/</span><span style="color: #a31515">configuration</span><span style="color: blue">&gt;    </span>
</div>
</pre>
<p>The root of the problem supposedly lies in EPiServer SDK integrated with Visual Studio and it’s Visual Studio that puts those lines there once you attempt to add a new element with one of its toolbars or use the Insert-&gt;New item… from File menu or context menu in Project Explorer.</p>
<p>Thanks to the guys on <a href="http://blog.najmanowicz.com/2007/05/08/epicode-hits-irc/">#epicode IRC channel</a> for helping out quickly with the problem.</p>
<img src="http://blog.najmanowicz.com/?ak_action=api_record_view&id=102&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.najmanowicz.com/2008/06/27/fix-for-episerver-cms5-interfering-with-your-episerver-4/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
