<?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>Fredrik Haglund's blog &#187; OwnerTab</title>
	<atom:link href="http://blog.fredrikhaglund.se/blog/tag/ownertab/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fredrikhaglund.se</link>
	<description>Chatter about EPiServer, ASP.NET, CSS and Web Development.</description>
	<lastBuildDate>Tue, 28 Jun 2011 13:37:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Move built-in property to another tab when editing</title>
		<link>http://blog.fredrikhaglund.se/blog/2009/06/08/move-built-in-property-to-another-tab-when-editing/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2009/06/08/move-built-in-property-to-another-tab-when-editing/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 06:30:00 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[OwnerTab]]></category>
		<category><![CDATA[TabDefinition]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/blog/2009/06/08/move-built-in-property-to-another-tab-when-editing/</guid>
		<description><![CDATA[One of our customers required that we limited access to the Advanced Information tab in edit mode for normal editors. A reasonable requirement but how do you enable normal editors to adjust the sort order? The answer is to move these built-in properties to a new tab. Where to I hook my Event in EPiServer? [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.fredrikhaglund.se/wp-content/uploads/2009/06/image.png"><img style="border-right-width: 0px; margin: 0px 0px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" align="right" src="http://blog.fredrikhaglund.se/wp-content/uploads/2009/06/image-thumb.png" width="240" height="145" /></a> One of our customers required that we limited access to the Advanced Information tab in edit mode for normal editors. A reasonable requirement but how do you enable normal editors to adjust the sort order? </p>
<p>The answer is to move these built-in properties to a new tab.</p>
<h3>Where to I hook my Event in EPiServer?</h3>
<p>In latest releases of EPiServer CMS you are not allowed to access come parts of EPiServer to early. That is why I hook <em>FirstBeginRequest</em> event on EPiServer <em>InitializationModule</em> during <em>Application_Start</em> in <em>Global.asax</em>. You could also do this in <em>Init()</em> of an <em>HttpModule</em>.</p>
<p>All initialization is then done in that Event handler. We start by loading the target <em>TabDefinition</em> to get the <em>ID</em> then we hook <em>EditPanel.LoadedPage</em>. </p>
<p>EditPanel is the user class implementing EPiServers editor interface and LoadedPage is a static event that is fired every time the editor is shown. A perfect hook to tweak the editor! </p>
<h3>Source Code in Global.asax.cs to change tab for properties </h3>
<pre class="csharpcode"><span class="kwrd">protected</span> <span class="kwrd">void</span> Application_Start(Object sender, EventArgs e)
{
    InitializationModule.FirstBeginRequest += InitializationModule_FirstBeginRequest;
}

<span class="kwrd">void</span> InitializationModule_FirstBeginRequest(<span class="kwrd">object</span> sender, EventArgs e)
{
    CreateEventToMovePageOrderPropertyToCustomTab();
}

<span class="kwrd">private</span> <span class="kwrd">int</span> pageOrderTabID;

<span class="kwrd">private</span> <span class="kwrd">void</span> CreateEventToMovePageOrderPropertyToCustomTab()
{
    <span class="kwrd">string</span> pageOrderTabName = WebConfigurationManager.AppSettings[<span class="str">&quot;PageOrderTab&quot;</span>];
    var pageOrderTab = TabDefinition.Load(pageOrderTabName);
    <span class="kwrd">if</span> (pageOrderTab!=<span class="kwrd">null</span>)
    {
        pageOrderTabID = pageOrderTab.ID;
        EditPanel.LoadedPage += EditPanel_LoadedPage;
    }
}

<span class="kwrd">void</span> EditPanel_LoadedPage(EditPanel sender, LoadedPageEventArgs e)
{
    e.Page.Property[<span class="str">&quot;PageChildOrderRule&quot;</span>].OwnerTab = pageOrderTabID;
    e.Page.Property[<span class="str">&quot;PagePeerOrder&quot;</span>].OwnerTab = pageOrderTabID;
}</pre>
<h3>Settings in web.config</h3>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">configuration</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;</span><span class="html">appSettings</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">add</span> <span class="attr">key</span><span class="kwrd">=&quot;PageOrderTab&quot;</span>
         <span class="attr">value</span><span class="kwrd">=&quot;Sidadministration&quot;</span><span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">appSettings</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">configuration</span><span class="kwrd">&gt;</span></pre>
<p>As usual, drop a comment if you think this is usefull! It is good for my blogging morale. <img src='http://blog.fredrikhaglund.se/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2009/06/08/move-built-in-property-to-another-tab-when-editing/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

