<?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>netrace.org</title>
	<atom:link href="http://www.netrace.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.netrace.org</link>
	<description>A .Net developer diary</description>
	<lastBuildDate>Mon, 17 Oct 2011 21:50:33 +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>File host /etc/host seems not working in Mac OSX Lion 10.7</title>
		<link>http://www.netrace.org/2011/10/17/file-host-etchost-seems-not-working-in-mac-osx-lion-10-7/</link>
		<comments>http://www.netrace.org/2011/10/17/file-host-etchost-seems-not-working-in-mac-osx-lion-10-7/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 21:49:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.netrace.org/?p=53</guid>
		<description><![CDATA[Sometimes, you need to override a dns public entry with a custom one. Of course, you&#8217;ll modify the hosts file. In Mac OS X, like in *nix operating system, it&#8217;s located in /etc/hosts and you can edit it using root permissions. But, in osx lion 10.7, your system will use the network DNS, then the [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, you need to override a dns public entry with a custom one.<br />
Of course, you&#8217;ll modify the hosts file.<br />
In Mac OS X, like in *nix operating system, it&#8217;s located in /etc/hosts and you can edit it using root permissions.<br />
But, in osx lion 10.7, your system will use the network DNS, then the hosts file.<br />
All you need to do, is to install a local DNS server &#8211; DNSMasq using MacPort, then add 127.0.0.1 as a DNS server and move it to first in network configuration panel.</p>
<p>As soon as possible I&#8217;ll post the steps necessary to get it working.<br />
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netrace.org/2011/10/17/file-host-etchost-seems-not-working-in-mac-osx-lion-10-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create XsltExtension and using in Umbraco 4.5</title>
		<link>http://www.netrace.org/2010/07/12/create-xsltextension-and-using-in-umbraco-4-5/</link>
		<comments>http://www.netrace.org/2010/07/12/create-xsltextension-and-using-in-umbraco-4-5/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 21:47:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Umbraco 4.5]]></category>

		<guid isPermaLink="false">http://www.netrace.org/?p=34</guid>
		<description><![CDATA[This post will explain how to create and use Xslt Extension in Umbraco 4.5.We will add few basic function we always needs in everyday coding. First of all, we need to create a class library project (you can add this project to your solution or create a new solution). All we need is to add [...]]]></description>
			<content:encoded><![CDATA[<p>This post will explain how to create and use Xslt Extension in Umbraco 4.5.We will add few basic function we always needs in everyday coding.<br />
First of all, we need to create a class library project (you can add this project to your solution or create a new solution). All we need is to add references to umbraco dlls. Generally umbraco, cms, interfaces and businesslogic will cover all our needs.</p>
<p>Now we will add a new class (for example, Library in Library.cs) and add two  methods: <em>QueryString</em> and <em>ToUpper:</em></p>
<pre class="c-sharp" name="code">public class Library
{
 public String QueryString(String key, String defaultValue)
 {
   return HttpContext.Current.Request.QueryString[key] ?? defaultValue;
 }

 public String ToUpper(String inputString)
 {
   return inputString.ToUpper();
 }
}</pre>
<p>Next, we need to put the output assembly in the Umbraco bin folder, then open the file /config/xsltExtension.config and add this line before the &lt;/XsltExtensions&gt; closing tag:</p>
<pre class="xml" name="code">
&lt;ext
  assembly="My.Umbraco.XsltExtensions"
  type="My.Umbraco.XsltExtensions.Library"
  alias="my" /&gt;
</pre>
<p>Finally, in our xslt files, we have to modify the xsl:stylesheet opening tag:</p>
<pre class="xslt" name="code">
&lt;xsl:stylesheet 
  version="1.0"  
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
  xmlns:msxml="urn:schemas-microsoft-com:xslt"
  xmlns:umbraco.library="urn:umbraco.library"
  xmlns:my="urn:my"
  exclude-result-prefixes="msxml umbraco.library my"&gt;</pre>
<p>and use our methods in this way:</p>
<pre class="xslt" name="code">
<xsl:value-of select="my:ToUpper($currentPage/exampleText)"/>
</pre>
<p>where exampleText is a dataType &#8220;textstring&#8221; of the current page document type.<br />
<br/><br />
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netrace.org/2010/07/12/create-xsltextension-and-using-in-umbraco-4-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autocomplete in Umbraco 4.5 using jQuery</title>
		<link>http://www.netrace.org/2010/07/12/autocomplete-in-umbraco-4-5-using-jquery/</link>
		<comments>http://www.netrace.org/2010/07/12/autocomplete-in-umbraco-4-5-using-jquery/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 21:21:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Umbraco 4.5]]></category>

		<guid isPermaLink="false">http://www.netrace.org/?p=20</guid>
		<description><![CDATA[I was searching too much, and never found something fast and useful. So I had to implmenet, using jQuery and the new Umbraco 4.5 a frontend feature everyone calls &#8220;AutoComplete&#8221;. Here it is my implementation; of course it could be faster and optimized, but this solution works pretty nice with the website i was working on. [...]]]></description>
			<content:encoded><![CDATA[<p>I was searching too much, and never found something fast and useful. So I had to implmenet, using jQuery and the new Umbraco 4.5 a frontend feature everyone calls &#8220;AutoComplete&#8221;.</p>
<p>Here it is my implementation; of course it could be faster and optimized, but this solution works pretty nice with the website i was working on.</p>
<p>First of all, we need jQuery on our website, I&#8217;m using the 1.4.2 version today. Next, we need the jQuery UI plugin downloadable from <a title="jQuery UI" href="http://jqueryui.com/demos/autocomplete/#remote" target="_blank">here</a> (remember the dependencies if you choose <em>custom download</em>).</p>
<p>When we could have this (I choosed the custom download) in our <em>head </em>tag:</p>
<pre class="html" name="code">&lt;script type="text/javascript" src="/scripts/jquery-1.4.2.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/scripts/jquery-ui-1.8.2.custom.min.js"&gt;&lt;/script&gt;</pre>
<p>we can go on.</p>
<p>Next step is to create the <em>remote datasource </em>for autocomplete. I suppose we needs to &#8220;autocomplete&#8221; only one of our document-types called <em>ExampleDoc</em>, ad I also suppose we have ad homepage tree node using <em>ExampleHome </em>as a document-type.</p>
<p>If you don&#8217;t use, we should create a node &#8220;<em>Services</em>&#8221; in our content tree. This node will contains services nodes will be never shown in menus or in website, but we use it for other purposes, like this example.</p>
<p>As a child of <em>Services </em>we create a node called &#8220;AutoComplete&#8221;. In the template (masterpage) corresponding to the document-type, we will add a <em>Umbraco Macro </em>referencing a new <em>xslt </em>file, we should AutoComplete.xslt.</p>
<p>The output I&#8217;m expecting is a json serialized object will be deserialized  by jQuery UI plugin we download before.</p>
<p>So i work in this way:</p>
<pre class="xslt" name="code">&lt;xsl:template match="/"&gt;
  [
  &lt;xsl:for-each select="$currentPage/ancestor-or-self::ExampleHome/descendant::ExampleDoc[@isDoc and starts-with(my:ToUpper(./@nodeName), my:ToUpper(my:QueryString('term','')))]"&gt;

    { "id": "&lt;xsl:value-of select="./@nodeName"/&gt;",
    "label": "&lt;xsl:value-of select="./@nodeName"/&gt;",
    "value": "&lt;xsl:value-of select="./@nodeName"/&gt;" }
    &lt;xsl:if test="position()!=last()"&gt;
      ,
    &lt;/xsl:if&gt;
  &lt;/xsl:for-each&gt;
  ]
&lt;/xsl:template&gt;</pre>
<blockquote><p>You can clearly see I use two custom functions (Xslt Extension): ToUpper and QueryString. <a title="Create XsltExtension and using in Umbraco 4.5" href="http://www.netrace.org/2010/07/12/create-xsltextension-and-using-in-umbraco-4-5/" target="_self">Here</a> it is a post shows how to create and use these methods in xslt files.</p></blockquote>
<p>Now, we just need to add this script to our page contains the search text-box:</p>
<pre class="javascript" name="code">$(function () {
  $("input#searchText").autocomplete({
    source: "/services/autocomplete.aspx",
    minLength: 2
  });
});</pre>
<p>where <em>/services/autocomplete.aspx</em> is the page corresponding to the page contains the macro just created.<br /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.netrace.org/2010/07/12/autocomplete-in-umbraco-4-5-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Breadcrumbs in Umbraco 4.5</title>
		<link>http://www.netrace.org/2010/07/11/breadcrumbs-in-umbraco-4-5/</link>
		<comments>http://www.netrace.org/2010/07/11/breadcrumbs-in-umbraco-4-5/#comments</comments>
		<pubDate>Sat, 10 Jul 2010 23:55:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Umbraco 4.5]]></category>

		<guid isPermaLink="false">http://www.netrace.org/?p=5</guid>
		<description><![CDATA[Working on a new website using the new Umbraco 4.5 (with the new xml schema), I had to write a new Breadcrumb xslt. So, let&#8217;s see how we can handle this feature: First, I&#8217;m assuming the HTML structure I wish at the end: &#60;div id="breadcrumb"&#62; &#60;ul&#62; &#60;li&#62; &#60;a href="/" title="Home"&#62;Home&#60;/a&#62; &#60;/li&#62; &#60;li&#62; &#60;a href="/parent.aspx" title="Parent"&#62;Parent&#60;/a&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Working on a new website using the new <strong>Umbraco 4.5</strong> (with the <strong>new xml schema</strong>), I had to write a new Breadcrumb xslt. </p>
<p>So, let&#8217;s see how we can handle this feature:</p>
<p>First, I&#8217;m assuming the HTML structure I wish at the end:</p>
<pre name="code" class="html">&lt;div id="breadcrumb"&gt;
  &lt;ul&gt;
    &lt;li&gt;
      &lt;a href="/" title="Home"&gt;Home&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;a href="/parent.aspx" title="Parent"&gt;Parent&lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;Current Page&lt;/li&gt;
  &lt;/ul&gt;
&lt;/div&gt;</pre>
<p>I&#8217;m assuming too my root DocumentType (the homepage one) is called &#8220;CommonHomePage&#8221; and my homepage url is the relative &#8220;/&#8221;.</p>
<p>Let&#8217;s begin with the &#8220;HOME&#8221; item we should manage in a different way than others:</p>
<pre name="code" class="xslt">        &lt;li&gt;
          &lt;xsl:choose&gt;
            &lt;xsl:when test="$currentPage/ancestor-or-self::CommonHomePage/@id = $currentPage/@id"&gt;
              &lt;xsl:value-of select="umbraco.library:GetDictionaryItem('Home')" /&gt;
            &lt;/xsl:when&gt;
            &lt;xsl:otherwise&gt;
              &lt;a href="/" title="{umbraco.library:GetDictionaryItem('Home')}"&gt;
                &lt;xsl:value-of select="umbraco.library:GetDictionaryItem('Home')" /&gt;
              &lt;/a&gt;
            &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
        &lt;/li&gt;</pre>
<p>With this piece of code, you&#8217;ll get Home with or without link based on current location.<br />
Now you should keep the &#8220;Home&#8221;-code, we will use it later.</p>
<p>Next, I will create a <strong>recursive</strong> xsl template:</p>
<pre name="code" class="xslt">  &lt;xsl:template name="innerNode"&gt;
    &lt;xsl:param name="node"/&gt;
        &lt;xsl:for-each select="$node/*[@isDoc]"&gt;
          &lt;xsl:if test="./descendant::*/@id = $currentPage/@id or ./@id = $currentPage/@id"&gt;
            &lt;li&gt;
              &lt;xsl:choose&gt;
                &lt;xsl:when test="not(./@id = $currentPage/@id)"&gt;
                  &lt;a href="{umbraco.library:NiceUrl(@id)}" title="{@nodeName}"&gt;
                    &lt;xsl:value-of select="@nodeName" /&gt;
                  &lt;/a&gt;
                &lt;/xsl:when&gt;
                &lt;xsl:otherwise&gt;
                  &lt;xsl:value-of select="@nodeName" /&gt;
                &lt;/xsl:otherwise&gt;
              &lt;/xsl:choose&gt;
            &lt;/li&gt;
          &lt;/xsl:if&gt;
          &lt;xsl:call-template name="innerNode"&gt;
            &lt;xsl:with-param name="node" select="."/&gt;
          &lt;/xsl:call-template&gt;
        &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;</pre>
<p>Now we can call this template from the &#8220;/&#8221; template:</p>
<pre name="code" class="xslt">  &lt;xsl:template match="/"&gt;
    &lt;div id="breadcrumb"&gt;
      &lt;ul&gt;
        &lt;xsl:call-template name="innerNode"&gt;
          &lt;xsl:with-param name="node" select="$currentPage/ancestor-or-self::CommonHomePage"/&gt;
        &lt;/xsl:call-template&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  &lt;/xsl:template&gt;</pre>
<p>And now it&#8217;s time to put the &#8220;Home&#8221; piece of code, so this is the full code:</p>
<pre name="code" class="xslt">>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE xsl:stylesheet [
  &lt;!ENTITY nbsp " "&gt;
]&gt;
&lt;xsl:stylesheet
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="msxml umbraco.library"&gt;

  &lt;xsl:output method="xml" omit-xml-declaration="yes" /&gt;

  &lt;xsl:param name="currentPage"/&gt;

  &lt;xsl:template match="/"&gt;
    &lt;div id="breadcrumb"&gt;
      &lt;ul&gt;
        &lt;li&gt;
          &lt;xsl:choose&gt;
            &lt;xsl:when test="$currentPage/ancestor-or-self::CommonHomePage/@id = $currentPage/@id"&gt;
              &lt;xsl:value-of select="umbraco.library:GetDictionaryItem('Home')" /&gt;
            &lt;/xsl:when&gt;
            &lt;xsl:otherwise&gt;
              &lt;a href="/" title="{umbraco.library:GetDictionaryItem('Home')}"&gt;
                &lt;xsl:value-of select="umbraco.library:GetDictionaryItem('Home')" /&gt;
              &lt;/a&gt;
            &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
        &lt;/li&gt;
        &lt;xsl:call-template name="innerNode"&gt;
          &lt;xsl:with-param name="node" select="$currentPage/ancestor-or-self::CommonHomePage"/&gt;
        &lt;/xsl:call-template&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
  &lt;/xsl:template&gt;

  &lt;xsl:template name="innerNode"&gt;
    &lt;xsl:param name="node"/&gt;
        &lt;xsl:for-each select="$node/*[@isDoc]"&gt;
          &lt;xsl:if test="./descendant::*/@id = $currentPage/@id or ./@id = $currentPage/@id"&gt;
            &lt;li&gt;
              &lt;xsl:choose&gt;
                &lt;xsl:when test="not(./@id = $currentPage/@id)"&gt;
                  &lt;a href="{umbraco.library:NiceUrl(@id)}" title="{@nodeName}"&gt;
                    &lt;xsl:value-of select="@nodeName" /&gt;
                  &lt;/a&gt;
                &lt;/xsl:when&gt;
                &lt;xsl:otherwise&gt;
                  &lt;xsl:value-of select="@nodeName" /&gt;
                &lt;/xsl:otherwise&gt;
              &lt;/xsl:choose&gt;
            &lt;/li&gt;
          &lt;/xsl:if&gt;
          &lt;xsl:call-template name="innerNode"&gt;
            &lt;xsl:with-param name="node" select="."/&gt;
          &lt;/xsl:call-template&gt;
        &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;</pre>
<blockquote><p>We have <em>$node/*[isDoc] </em>because the new XML schema.<br />
Each child of <em>$node </em>now have as its nodename its alias. The empty attribute isDoc ensured it is a Document-Node, and not a Property-node.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.netrace.org/2010/07/11/breadcrumbs-in-umbraco-4-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

