<?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>Didsbury Design Blog &#187; Development</title>
	<atom:link href="http://blog.didsburydesign.com/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.didsburydesign.com</link>
	<description>Web Design and Development</description>
	<lastBuildDate>Fri, 04 Nov 2011 16:37:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Matching a W3wp Process to an Application Pool / IIS Site</title>
		<link>http://blog.didsburydesign.com/2011/11/matching-a-w3wp-process-to-an-application-pool-iis-site/</link>
		<comments>http://blog.didsburydesign.com/2011/11/matching-a-w3wp-process-to-an-application-pool-iis-site/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 16:37:21 +0000</pubDate>
		<dc:creator>Didsbury Design</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[w3p.exe]]></category>

		<guid isPermaLink="false">http://blog.didsburydesign.com/?p=323</guid>
		<description><![CDATA[OK so maybe you are trying to:

Debug a website
Debug a web service
Debug another .NET app

 So you go into Visual Studio, Debug menu, Attach to process&#8230;
SO you are looking for the w3p.exe process, but there are loads! 
Here is how to match up which process related to your application pool or IIS site.
Server 2003
Open a [...]]]></description>
			<content:encoded><![CDATA[<p>OK so maybe you are trying to:</p>
<ul>
<li>Debug a website</li>
<li>Debug a web service</li>
<li>Debug another .NET app</li>
</ul>
<p> So you go into Visual Studio, Debug menu, Attach to process&#8230;</p>
<p>SO you are looking for the w3p.exe process, but there are loads! </p>
<p>Here is how to match up which process related to your application pool or IIS site.</p>
<p><strong>Server 2003</strong><br />
Open a command prompt (run as administrator)<br />
C:\Windows\System32\inetsrv>cscript.exe C:\Windows\System32\system32\iisapp.vbs</p>
<p><strong>Server 2008</strong><br />
Open a command prompt (run as administrator)<br />
%windir%\system32\inetsrv\appcmd.exe list wp</p>
<p>If you get an error WAS service not started &#8211; make sure you opened command prompt as an administrator!</p>
<p>Hope this helps someone else quickly attach to the right process.</p>
<p>Alternatively attach to them all if you are lazy <img src='http://blog.didsburydesign.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.didsburydesign.com/2011/11/matching-a-w3wp-process-to-an-application-pool-iis-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Canonical URLs in your ASP.NET MVC2 / MVC3 Application</title>
		<link>http://blog.didsburydesign.com/2010/11/canonical-urls-in-your-asp-net-mvc2-mvc3-application/</link>
		<comments>http://blog.didsburydesign.com/2010/11/canonical-urls-in-your-asp-net-mvc2-mvc3-application/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 12:43:11 +0000</pubDate>
		<dc:creator>Didsbury Design</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[MVC2]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C-Sharp]]></category>
		<category><![CDATA[canonical]]></category>
		<category><![CDATA[Filter attribute]]></category>
		<category><![CDATA[MVC3]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://blog.didsburydesign.com/?p=276</guid>
		<description><![CDATA[What are canonical links used for
The Canonical link element was introduced in 2009 to help cleanup duplicate pages on search engines.
The html code is shown below and it basically informs search engines of the primary URL for that page. This means any alternative entry points to that page will not be picked up as duplicate [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What are canonical links used for</strong><br />
The Canonical link element was introduced in 2009 to help cleanup duplicate pages on search engines.<br />
The html code is shown below and it basically informs search engines of the primary URL for that page. This means any alternative entry points to that page will not be picked up as duplicate content. This HTML must be specified in the HEAD section of the document.</p>

<div class="wp_syntax"><div class="code"><pre class="xhtml" style="font-family:monospace;">&lt;link rel=&quot;canonical&quot; href=&quot;http://example.com/page.html&quot;/&gt;</pre></div></div>

<p>The search engines have also posted about this on a Google <a href="http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html">blog post</a> or <a href="http://google.com/support/webmasters/bin/answer.py?answer=139394">help center documentation</a> from Google, <a href="http://ysearchblog.com/2009/02/12/fighting-duplication-adding-more-arrows-to-your-quiver/">Yahoo’s blog post</a>, or <a href="http://blogs.msdn.com/webmaster/archive/2009/02/12/partnering-to-help-solve-duplicate-content-issues.aspx">Microsoft’s blog post</a>.</p>
<p><strong>How to easily use canonical links in MVC2 using Action Filters and Master Pages</strong></p>
<p>Add this to the master page in the head section as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">    <span style="color: #339933;">&lt;%=</span>ViewData<span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;CanonicalURL&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">%&gt;</span>
    <span style="color: #339933;">&lt;!--</span>Your other head info here<span style="color: #339933;">--&gt;</span></pre></div></div>

<p>Create a Filter Attribute (CanonicalURL.cs):</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">public class CanonicalURL <span style="color: #339933;">:</span> ActionFilterAttribute
<span style="color: #009900;">&#123;</span>
    public <span style="color: #993333;">string</span> Url <span style="color: #009900;">&#123;</span> get<span style="color: #339933;">;</span> private set<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
    public CanonicalURL<span style="color: #009900;">&#40;</span><span style="color: #993333;">string</span> url<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
       Url <span style="color: #339933;">=</span> url<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    public override <span style="color: #993333;">void</span> OnResultExecuting<span style="color: #009900;">&#40;</span>ResultExecutingContext filterContext<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">string</span> fullyQualifiedUrl <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;http://www.example.com&quot;</span> <span style="color: #339933;">+</span> this.<span style="color: #202020;">Url</span><span style="color: #339933;">;</span>
        filterContext.<span style="color: #202020;">Controller</span>.<span style="color: #202020;">ViewData</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;CanonicalUrl&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> @<span style="color: #ff0000;">&quot;&lt;link rel='canonical' href='&quot;</span> <span style="color: #339933;">+</span> fullyQualifiedUrl <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;' /&gt;&quot;</span><span style="color: #339933;">;</span>
        base.<span style="color: #202020;">OnResultExecuting</span><span style="color: #009900;">&#40;</span>filterContext<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Call this from your actions:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>CanonicalURL<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Contact-Us&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span>
public ActionResult Index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
      ContactFormViewModel contact <span style="color: #339933;">=</span> new ContactFormViewModel<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
      <span style="color: #b1b100;">return</span> View<span style="color: #009900;">&#40;</span>contact<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>For some other interesting articles on Search Engine Related posts check out <a href="http://www.mattcutts.com/blog/canonical-link-tag/" rel="nofollow">Matt Cutts blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.didsburydesign.com/2010/11/canonical-urls-in-your-asp-net-mvc2-mvc3-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC 3 Release Candidate is now available</title>
		<link>http://blog.didsburydesign.com/2010/11/asp-net-mvc-3-release-candidate-is-now-available/</link>
		<comments>http://blog.didsburydesign.com/2010/11/asp-net-mvc-3-release-candidate-is-now-available/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 11:23:06 +0000</pubDate>
		<dc:creator>Didsbury Design</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C-Sharp]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[mvc 3.0 RC]]></category>

		<guid isPermaLink="false">http://blog.didsburydesign.com/?p=266</guid>
		<description><![CDATA[ASP.NET MVC 3 Release Candidate is now available for download. Phil Haack has written an article about it and also mentions the intentions for MVC 4.
Phil Haack&#8217;s blog post: ASP.NET MVC 3 Release Candidate

Direct download: MVC 3 RC Download
]]></description>
			<content:encoded><![CDATA[<p>ASP.NET MVC 3 Release Candidate is now available for download. Phil Haack has written an article about it and also mentions the intentions for MVC 4.</p>
<p>Phil Haack&#8217;s blog post: <a href="http://haacked.com/archive/2010/11/09/asp-net-mvc-3-release-candidate.aspx?utm_source=feedburner&#038;utm_medium=feed&#038;utm_campaign=Feed%3A+haacked+%28you%27ve+been+HAACKED%29">ASP.NET MVC 3 Release Candidate<br />
</a></p>
<p>Direct download: <a href="http://go.microsoft.com/fwlink/?LinkID=191797">MVC 3 RC Download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.didsburydesign.com/2010/11/asp-net-mvc-3-release-candidate-is-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: Create and Delete a cookie in ASP.NET C#</title>
		<link>http://blog.didsburydesign.com/2010/04/how-to-create-and-delete-a-cookie-in-asp-net-c/</link>
		<comments>http://blog.didsburydesign.com/2010/04/how-to-create-and-delete-a-cookie-in-asp-net-c/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 12:27:55 +0000</pubDate>
		<dc:creator>Didsbury Design</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C-Sharp]]></category>
		<category><![CDATA[cookie]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.zero7web.com/?p=232</guid>
		<description><![CDATA[I thought I would do a quick post about Creating and more importantly Deleting cookies in ASP.NET as it&#8217;s not quite as obvious as it may seem with the misleading .Remove() method which doesnt do as you would expect.
I hope this helps someone get started with cookies if your just getting started with the .NET [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I would do a quick post about Creating and more importantly Deleting cookies in ASP.NET as it&#8217;s not quite as obvious as it may seem with the misleading .Remove() method which doesnt do as you would expect.</p>
<p>I hope this helps someone get started with cookies if your just getting started with the .NET framework.<br />
</p>
<h2>Creating a cookie</h2>
<p>
This is a basic example of how to create a cookie in ASP.NET C#<br />
 </p>
<pre>//Create a new cookie, passing the name into the constructor
HttpCookie cookie = new HttpCookie("MyCookie");

//Set the cookies value
cookie.Value = "CookieValue";

//Set the cookie to expire in 1 day
cookie.Expires = DateTime.Now.AddDays(1);

//Add the cookie
Response.Cookies.Add(cookie);</pre>
<h2>Deleting a cookie</h2>
<p>
When deleting a cookie all you need to do is amend the HttpCookie object so it has an expiry date in the past, then re-save the cookie to push the new value to the client.<br />
</p>
<pre>// Clear cookie Info
            if(Request.Cookies["MyCookie"]!=null){

                HttpCookie cookie = Request.Cookies["MyCookie"];
                cookie.Expires = DateTime.Now.AddDays(-1);

                Response.Cookies.Add(cookie);
            }</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.didsburydesign.com/2010/04/how-to-create-and-delete-a-cookie-in-asp-net-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: Allow hyphens in URL&#8217;s using ASP.NET MVC 2</title>
		<link>http://blog.didsburydesign.com/2010/02/how-to-allow-hyphens-in-urls-using-asp-net-mvc-2/</link>
		<comments>http://blog.didsburydesign.com/2010/02/how-to-allow-hyphens-in-urls-using-asp-net-mvc-2/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 14:28:03 +0000</pubDate>
		<dc:creator>Didsbury Design</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C-Sharp]]></category>
		<category><![CDATA[Hyphens]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[MVC 2.0]]></category>
		<category><![CDATA[URL Routing]]></category>

		<guid isPermaLink="false">http://blog.zero7web.com/?p=200</guid>
		<description><![CDATA[If you wan&#8217;t to allow hyphens in your URL&#8217;s you will need to change the way the routing works in your Global.asax file.
First create a new class which extends the MvcRouteHandler and place this in the Global.asax file after the main MvcApplication class.
C#:

public class HyphenatedRouteHandler : MvcRouteHandler&#123;
	protected override IHttpHandler  GetHttpHandler&#40;RequestContext requestContext&#41;
	&#123;
		requestContext.RouteData.Values&#91;&#34;controller&#34;&#93; = requestContext.RouteData.Values&#91;&#34;controller&#34;&#93;.ToString&#40;&#41;.Replace&#40;&#34;-&#34;, &#34;_&#34;&#41;;
		requestContext.RouteData.Values&#91;&#34;action&#34;&#93; [...]]]></description>
			<content:encoded><![CDATA[<p>If you wan&#8217;t to allow hyphens in your URL&#8217;s you will need to change the way the routing works in your Global.asax file.</p>
<p>First create a new class which extends the <strong>MvcRouteHandler</strong> and place this in the <strong>Global.asax</strong> file after the main <strong>MvcApplication</strong> class.</p>
<p>C#:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">public class HyphenatedRouteHandler <span style="color: #339933;">:</span> MvcRouteHandler<span style="color: #009900;">&#123;</span>
	protected override IHttpHandler  GetHttpHandler<span style="color: #009900;">&#40;</span>RequestContext requestContext<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		requestContext.<span style="color: #202020;">RouteData</span>.<span style="color: #202020;">Values</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;controller&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> requestContext.<span style="color: #202020;">RouteData</span>.<span style="color: #202020;">Values</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;controller&quot;</span><span style="color: #009900;">&#93;</span>.<span style="color: #202020;">ToString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #202020;">Replace</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;-&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;_&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		requestContext.<span style="color: #202020;">RouteData</span>.<span style="color: #202020;">Values</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;action&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> requestContext.<span style="color: #202020;">RouteData</span>.<span style="color: #202020;">Values</span><span style="color: #009900;">&#91;</span><span style="color: #ff0000;">&quot;action&quot;</span><span style="color: #009900;">&#93;</span>.<span style="color: #202020;">ToString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #202020;">Replace</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;-&quot;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;_&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> base.<span style="color: #202020;">GetHttpHandler</span><span style="color: #009900;">&#40;</span>requestContext<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>VB:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Public</span> Class HyphenatedRouteHandler
    Inherits MvcRouteHandler
&nbsp;
    Protected Overrides <span style="color: #000080;">Function</span> GetHttpHandler(<span style="color: #000080;">ByVal</span> requestContext <span style="color: #000080;">As</span> System.Web.Routing.RequestContext) <span style="color: #000080;">As</span> System.Web.IHttpHandler
        requestContext.RouteData.Values(&quot;controller&quot;) = requestContext.RouteData.Values(&quot;controller&quot;).ToString.Replace(&quot;-&quot;, &quot;_&quot;)
        requestContext.RouteData.Values(&quot;action&quot;) = requestContext.RouteData.Values(&quot;action&quot;).ToString.Replace(&quot;-&quot;, &quot;_&quot;)
        Return MyBase.GetHttpHandler(requestContext)
    <span style="color: #000080;">End</span> <span style="color: #000080;">Function</span>
&nbsp;
<span style="color: #000080;">End</span> Class</pre></div></div>

<p>Then you need to replace the <strong>routes.MapRoute</strong> with an equivalent <strong>routes.Add</strong> specifying the new handler as the MapRoute does not allow you to specify a custom route handler.</p>
<p>C#:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;">routes.<span style="color: #202020;">Add</span><span style="color: #009900;">&#40;</span>
	new Route<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;{controller}/{action}/{id}&quot;</span><span style="color: #339933;">,</span> 
		new RouteValueDictionary<span style="color: #009900;">&#40;</span>
			new <span style="color: #009900;">&#123;</span> controller <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Default&quot;</span><span style="color: #339933;">,</span> action <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;Index&quot;</span><span style="color: #339933;">,</span> id <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			new HyphenatedRouteHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>VB:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">routes.Add(<span style="color: #000080;">New</span> Route(&quot;{controller}/{action}/{id}&quot;, 
	<span style="color: #000080;">New</span> RouteValueDictionary(<span style="color: #000080;">New</span> <span style="color: #000080;">With</span> {.controller = &quot;Home&quot;, .action = &quot;Index&quot;, .id = &quot;&quot;}), 
		<span style="color: #000080;">New</span> HyphenatedRouteHandler()))</pre></div></div>

<p>I hope this is useful, any questions feel free to get in touch.</p>
<p>Would like to say thanks to John from <a href="http://stackoverflow.com/questions/2070890/asp-net-mvc-support-for-urls-with-hyphens">here</a> for answering the original question on <a href="http://stackoverflow.com">Stackoverflow</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.didsburydesign.com/2010/02/how-to-allow-hyphens-in-urls-using-asp-net-mvc-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC 2 RC 2 Released</title>
		<link>http://blog.didsburydesign.com/2010/02/asp-net-mvc-2-rc-2-released/</link>
		<comments>http://blog.didsburydesign.com/2010/02/asp-net-mvc-2-rc-2-released/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 10:02:52 +0000</pubDate>
		<dc:creator>Didsbury Design</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[MVC 2.0 RC"]]></category>
		<category><![CDATA[Phil Haack]]></category>

		<guid isPermaLink="false">http://blog.zero7web.com/?p=198</guid>
		<description><![CDATA[Today ASP.NET MVC 2 RC2 has been released.
To download it click here
It seems there are only a few changes to this release which you can find here: Release Notes
A few words from Phil Haack&#8217;s blog:
The biggest change in this release was described by Brad Wilson in his blog post on Input Validation vs. Model Validation [...]]]></description>
			<content:encoded><![CDATA[<p>Today ASP.NET MVC 2 RC2 has been released.</p>
<p>To download it <a href="http://go.microsoft.com/fwlink/?LinkID=182483">click here</a></p>
<p>It seems there are only a few changes to this release which you can find here: <a href="http://go.microsoft.com/fwlink/?LinkID=182482">Release Notes</a></p>
<p>A few words from Phil Haack&#8217;s blog:</p>
<blockquote><p>The biggest change in this release was described by Brad Wilson in his blog post on <a href="http://bradwilson.typepad.com/blog/2010/01/input-validation-vs-model-validation-in-aspnet-mvc.html">Input Validation vs. Model Validation in ASP.NET MVC</a>. Also included in this release are an assortment of bug fixes and performance improvements.</p>
<p>The window to provide feedback on this release is going to be very short as we are closing in on the RTM. If you want to provide input into this release, please do take the bits for a spin as soon as possible. I’m pretty excited about this release as I can see the end of the tunnel fast approaching. <img src='http://blog.didsburydesign.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>At this point, we’ll only be taking recall class bugs for ASP.NET MVC 2. All other bug reports will be filed against ASP.NET MVC 3. Sometime in the near future, I’ll start sharing some of our planning around that. How exciting!</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.didsburydesign.com/2010/02/asp-net-mvc-2-rc-2-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook launch HipHop, a sourcecode-converter from php to c++</title>
		<link>http://blog.didsburydesign.com/2010/02/facebook-launch-hiphop-a-sourcecode-converter-from-php-to-c/</link>
		<comments>http://blog.didsburydesign.com/2010/02/facebook-launch-hiphop-a-sourcecode-converter-from-php-to-c/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 12:00:14 +0000</pubDate>
		<dc:creator>Didsbury Design</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[hiphop]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[speed]]></category>

		<guid isPermaLink="false">http://blog.zero7web.com/?p=186</guid>
		<description><![CDATA[Yesterday Facebook launched HipHop, a converter from php to c++ so your apps can run twice as fast due to them being compiled not interpreted.
Today I&#8217;m excited to share the project a small team of amazing people and I have been working on for the past two years; HipHop for PHP. With HipHop we&#8217;ve reduced [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday Facebook launched HipHop, a converter from php to c++ so your apps can run twice as fast due to them being compiled not interpreted.</p>
<blockquote><p>Today I&#8217;m excited to share the project a small team of amazing people and I have been working on for the past two years; HipHop for PHP. With HipHop we&#8217;ve reduced the CPU usage on our Web servers on average by about fifty percent, depending on the page. Less CPU means fewer servers, which means less overhead. This project has had a tremendous impact on Facebook. We feel the Web at large can benefit from HipHop, so we are releasing it as open source this evening in hope that it brings a new focus toward scaling large complex websites with PHP. While HipHop has shown us incredible results, it&#8217;s certainly not complete and you should be comfortable with beta software before trying it out. &#8211; <a href="http://developers.facebook.com/news.php?blog=1&#038;story=358">Haiping Zhao (Facebook)</a></p></blockquote>
<p>HipHop is for scaling large multiserver high traffic sites like Facebook. In your regular application, you will get no great advantage from it. It is definately something to be aware of but it does make you think if your trying to compile PHP using a tool like this why not develop in C# (<a href="http://www.asp.net/mvc/">ASP.NET MVC 2 maybe?</a>) that is compiled anyway?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.didsburydesign.com/2010/02/facebook-launch-hiphop-a-sourcecode-converter-from-php-to-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What are RSS and Atom Feeds and how do I create them?</title>
		<link>http://blog.didsburydesign.com/2009/11/what-are-rss-and-atom-feeds-and-how-do-i-create-them/</link>
		<comments>http://blog.didsburydesign.com/2009/11/what-are-rss-and-atom-feeds-and-how-do-i-create-them/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 21:36:38 +0000</pubDate>
		<dc:creator>Didsbury Design</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[atom]]></category>
		<category><![CDATA[feeds]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rss]]></category>
		<category><![CDATA[rss2.0]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.zero7web.com/?p=131</guid>
		<description><![CDATA[What are feeds?
Really Simple Syndication (RSS) and Atom feeds are different formats used to publish updates or changes such as new blog entries, news entries or user activity in a standard format. The feed is basically an XML document containing certain information about the updated content.
What information do they contain?
The “feed”, “web feed” or “channel” [...]]]></description>
			<content:encoded><![CDATA[<h2>What are feeds?</h2>
<p>Really Simple Syndication (RSS) and Atom feeds are different formats used to publish updates or changes such as new blog entries, news entries or user activity in a standard format. The feed is basically an XML document containing certain information about the updated content.</p>
<h2>What information do they contain?</h2>
<p>The “feed”, “web feed” or “channel”  includes full or summarised text, plus metadata such as published date, category and authorship.</p>
<h2>Should I use RSS or Atom?</h2>
<p>RSS is more widely used as it was around first although the Atom feed standards seen to have a better structure I personally would stick with RSS 2.0 as it will work on all readers and software, and people are familiar with the term RSS.</p>
<h2>Why should I use a feed on my website?</h2>
<p>Web feeds make it easy to inform people of changes to your website. Anyone interested in your feed can subscribe to it via an RSS reader which can then keep track of updates for you. You can use fees in outlook, through the browser or through many desktop applications available.</p>
<h2>How can I create a feed?</h2>
<p>I will talk you through a very basic example of a feed to get you started but if your interested in taking it further you should read the <a href="http://www.rssboard.org/rss-specification">RSS 2.0 specs</a> and also those for <a href="http://www.atomenabled.org/developers/syndication/atom-format-spec.php">Atom feeds</a>.</p>
<p>You can either generate the feed manually or dynamically, but either way the end result will be structured the same.</p>
<p>Below is an example of a RSS document (XML).</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rss</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;channel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Social Addict Feed<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>This shows the latest updates on socialaddict.co.uk<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://www.socialaddict.co.uk<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>HOUSJUNKI :: BOXING DAY :: 26.12.09 :: CLUB.V<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://www.socialaddict.co.uk/events/single-event?eID=91<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/link<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Event added: HOUSJUNKI :: BOXING DAY :: 26.12.09 :: CLUB.V @ Club Venus by andoi - Sat 21st Nov 2009 8:19pm<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/description<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>EVENT<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/category<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pubDate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Sat, 21 Nov 2009 20:19:40 +0000<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pubDate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;copyright<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>(c) Social Addict 2009<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/copyright<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/item<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/channel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rss<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>Creating a static feed</h2>
<p>Simply take the code you have produced like above and save it as an XML document, rss.xml will be fine and then upload to your website. You take give out a direct link to the feed or if you would like users of the website to pick up that it exists automatically then simply add the following code into the head area of the HTML code.</p>

<div class="wp_syntax"><div class="code"><pre class="xhtml" style="font-family:monospace;">&lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;RSS Feed&quot; href=&quot;rss.xml&quot; /&gt;</pre></div></div>

<h2>Dynamically creating a feed using PHP</h2>
<p>If you have a dynamic (database driven) website then it would make more sense to dynamically generate the feed.</p>
<p>We have recently made a feed for a client site ( <a href="http://www.socialaddict.co.uk/rss">www.socialaddict.co.uk/rss</a> ) and we had to bring together the data from several different tables and merge them so the feed could take all updates into account. </p>
<p>We used the <a href="http://daniel.lorch.cc/projects/rss2writer/">RSS2Writer</a> class to generate the XML document which simplies the use of the PHP XMLWriter object. Grab yourself a copy of the class and you can use the example below to help get you started.</p>
<p>This is assuming you have a mySQL database with a table called &#8220;updates&#8221; and it contains:</p>
<p>`title`  VARCHAR<br />
`category` VARCHAR<br />
`info` VARCHAR<br />
`url` VARCHAR<br />
`created` DATETIME</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
try <span style="color: #009900;">&#123;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// Create RSS writer</span>
  <span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'includes/RSS2Writer.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$rss</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> rss2writer<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Social Addict Feed'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'This shows the latest updates on    socialaddict.co.uk'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'http://www.socialaddict.co.uk'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Create Database connection</span>
    <span style="color: #000088;">$dbh</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PDO<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql:host=localhost;dbname=test'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'username, '</span>password<span style="color: #0000ff;">'); // put your database details in here
    // Get data and iterate through it
    foreach($dbh-&gt;query('</span>SELECT `title`<span style="color: #339933;">,</span>`category`<span style="color: #339933;">,</span>`info`<span style="color: #339933;">,</span>`url`<span style="color: #339933;">,</span>`created` from updates<span style="color: #0000ff;">') as $feed) {
&nbsp;
        // Get each feed item information
	$rss-&gt;addItem($feed['</span>title<span style="color: #0000ff;">'], $feed['</span>info<span style="color: #0000ff;">'], $feed['</span>url<span style="color: #0000ff;">'], true);
	$rss-&gt;addElement('</span>category<span style="color: #0000ff;">', $feed['</span>category<span style="color: #0000ff;">']);
	$rss-&gt;addElement('</span>pubDate<span style="color: #0000ff;">', date(&quot;r&quot;,strtotime($feed['</span>created<span style="color: #0000ff;">'])));
	$rss-&gt;addElement('</span>copyright<span style="color: #0000ff;">', '</span><span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> Social Addict <span style="color: #cc66cc;">2009</span><span style="color: #0000ff;">');
	$rss-&gt;closeItem();
&nbsp;
    }
    $dbh = null;
&nbsp;
    // Set header type to XML
    header('</span>Content<span style="color: #339933;">-</span>type<span style="color: #339933;">:</span> text<span style="color: #339933;">/</span>xml<span style="color: #0000ff;">');
&nbsp;
   //$rss-&gt;writeToFile('</span>rss<span style="color: #339933;">.</span>xml<span style="color: #0000ff;">'); //write the xml output to file (optional)
   echo $rss-&gt;getXML(); // Output XML to browser / screen
&nbsp;
// Catch any errors
} catch (PDOException $e) {
    print &quot;An error occured: &quot; . $e-&gt;getMessage() . &quot;&lt;br/&gt;&quot;;
    die();
}
?&gt;</span></pre></div></div>

<p>Any questions are welcome, and we also help people out where we can.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.didsburydesign.com/2009/11/what-are-rss-and-atom-feeds-and-how-do-i-create-them/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: detect URLs in text and convert to html links (PHP using regular expressions)</title>
		<link>http://blog.didsburydesign.com/2009/10/how-to-detect-urls-in-text-and-convert-to-html-links-php-using-regular-expressions/</link>
		<comments>http://blog.didsburydesign.com/2009/10/how-to-detect-urls-in-text-and-convert-to-html-links-php-using-regular-expressions/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 21:53:26 +0000</pubDate>
		<dc:creator>Didsbury Design</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[preg_replace]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[url detection]]></category>

		<guid isPermaLink="false">http://blog.zero7ict.com/?p=112</guid>
		<description><![CDATA[I was trying to find a way of picking up URLs from user&#8217;s posts and converting them to HTML links. I found a few examples on the net that didn&#8217;t work for multiple URLs so I thought i would post a simple solution.
I have used the PHP preg_replace function

1
2
3
4
5
6
7
8
9
10
11
&#60;?php
// The Regular Expression filter
$pattern = &#34;/(http&#124;https&#124;ftp&#124;ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/&#34;;
&#160;
//example [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to find a way of picking up URLs from user&#8217;s posts and converting them to HTML links. I found a few examples on the net that didn&#8217;t work for multiple URLs so I thought i would post a simple solution.</p>
<p>I have used the PHP <a href="http://uk3.php.net/manual/en/function.preg-replace.php">preg_replace</a> function</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// The Regular Expression filter</span>
<span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//example text</span>
<span style="color: #000088;">$text</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example user text with a URL http://www.zero7web.com , second link http://www.didsburydesign.co.uk&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// convert URLs into Links</span>
<span style="color: #000088;">$text</span><span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&lt;a href=<span style="color: #000099; font-weight: bold;">\&quot;</span>\<span style="color: #660099; font-weight: bold;">\0</span><span style="color: #000099; font-weight: bold;">\&quot;</span>?phpMyAdmin=uMSzDU7o3aUDmXyBqXX6JVQaIO3&amp;phpMyAdmin=8d6c4cc61727t4d965138r21cd rel=<span style="color: #000099; font-weight: bold;">\&quot;</span>nofollow<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;\<span style="color: #660099; font-weight: bold;">\0</span>&lt;/a&gt;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">echo</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>This will match all the URL&#8217;s in the text and not just the first one like so many of the example on the web seem to do!!</p>
<p>I will post a C# .net version of this as a follow up in the next day or so.</p>
<p>All comments welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.didsburydesign.com/2009/10/how-to-detect-urls-in-text-and-convert-to-html-links-php-using-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To: Make a website that allows for multiple languages</title>
		<link>http://blog.didsburydesign.com/2009/04/how-to-make-a-website-that-allows-for-multiple-languages/</link>
		<comments>http://blog.didsburydesign.com/2009/04/how-to-make-a-website-that-allows-for-multiple-languages/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 22:10:11 +0000</pubDate>
		<dc:creator>Didsbury Design</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[convertor]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[foreign]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[multi-lingual]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[polish]]></category>
		<category><![CDATA[translation]]></category>

		<guid isPermaLink="false">http://blog.zero7ict.com/?p=24</guid>
		<description><![CDATA[So you have an old website or even a current one and you not have the need for several languages because of the traffic your getting. There are many ways of doing this and im giving a fairly simplistic method (simple is not a bad thing in this case). I will be doing this tutorial [...]]]></description>
			<content:encoded><![CDATA[<p>So you have an old website or even a current one and you not have the need for several languages because of the traffic your getting. There are many ways of doing this and im giving a fairly simplistic method (simple is not a bad thing in this case). I will be doing this tutorial in a few programming languages but i will first show you in PHP as its my favourite <img src='http://blog.didsburydesign.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span style="text-decoration: underline;"><strong>PHP METHOD</strong></span></p>
<p>I will break this down into a few stages for you. Im going to assume that you have some header text you need to be multi lingual and the navigation links (but this is really irrelevant as you can use this method wherever you need). This is designed for the static content on your pages (i will cover a similar method for DB driven content as soon as someone requests it or i get chance!)</p>
<p><strong>Breakdown of Tasks</strong></p>
<ol>
<li>create languages folder in your web root (or wherever you want on your web server)</li>
<li>create english.php file within that for starters</li>
<li>create definitions within that file, one for each static piece of text</li>
<li>create index.php and create drop down language selector</li>
<li>include the correct language file dependant on the selected language (stored in session data)</li>
<li>substitute your static bits of text with the relevant definition call</li>
<li>Enjoy your multi language website <img src='http://blog.didsburydesign.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<p><strong></strong></p>
<p><strong>OK lets get started&#8230;</strong></p>
<p><strong>1. c</strong><strong>reate languages folder in your web root (or wherever you want on your web server)</strong></p>
<p>OK im going to recommend creating a new folder in your website root called <strong>languages. </strong>This will be used to hold all your language definition files.</p>
<p><strong>2. create english.php definition file</strong></p>
<p>I&#8217;m using English as my example but name this after one of the languages you require and create the blank file called english.php in the <strong>languages folder. </strong></p>
<p><strong></strong></p>
<p><strong>3. create definitions within that file, one for each static piece of text</strong></p>
<p>Edit the new language files in your editor of choice and add the following code (use your own names to define areas on your site you get the idea)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;agHeader&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Hello im a title&quot;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;agNavigationLink&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Hello im a link&quot;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>save the file. Now make a copy of this file in the same folder and call it for example &#8220;polish.php&#8221; and keep the definition names the same <strong>THIS IS CRUCIAL. </strong>Change the values though to the new language see below for a polish example!</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;agHeader&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Czesc jestem tytuł&quot;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;agNavigationLink&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Czesc jestem hyperłączność&quot;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>4. create index.php and create drop down language selector</strong></p>
<p>Create a new index.php file outside of the language folder and within it we need to have a drop down list to select the language we require. Once this is selected we also need to store the language so that when we navigate away from the page the settings are remember. For this we will use sessions.</p>
<p>My Dropdown box code is like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;form action=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #990000;">echo</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_SELF'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; method=&quot;post&quot;&gt;
    &lt;select name=&quot;language&quot;&gt;
        &lt;option value=&quot;english&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'language'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;english&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot; selected=selected&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;English&lt;/option&gt;
        &lt;option value=&quot;polish&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'language'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;polish&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&quot; selected=selected&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;Polish&lt;/option&gt;
    &lt;/select&gt;
    &lt;input type=&quot;submit&quot; value=&quot;Change&quot; name=&quot;submit&quot; /&gt;
&lt;/form&gt;</pre></td></tr></table></div>

<p>this will submit to itself when a language is selected and as you can see, it will automatically start at the current language using a quick check on the SESSION variable we are going to use.</p>
<p><strong>5. include the correct language file dependant on the selected language</strong></p>
<p>At the very top of the file i have started the session and done a couple of things. First check if the language has been posted via the form, if it has then it will be stored in a session variable. The next thing that is done is using the session data the language definition is included using a switch statement and not the form data directly for security reasons. We also use the PHP5 filter_input() function to be safe when setting the session data.</p>
<p>This is the code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">session_start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'language'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'language'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span> filter_input<span style="color: #009900;">&#40;</span>INPUT_POST<span style="color: #339933;">,</span> ‘language’<span style="color: #339933;">,</span> FILTER_SANITIZE_SPECIAL_CHARS<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//filter the posted data just for security</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SESSION</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'language'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">case</span> “polish”<span style="color: #339933;">:</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span>”languages<span style="color: #339933;">/</span>polish<span style="color: #339933;">.</span>php”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span>”languages<span style="color: #339933;">/</span>english<span style="color: #339933;">.</span>php”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>6. substitute your static bits of text with the relevant definition call</strong></p>
<p>Last step where you want your text to appear you simple echo out your definitions like so</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #990000;">echo</span> agHeader<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><strong>7. Complete!</strong></p>
<p>Thats it!! Below i&#8217;ve given a link to the example files and an online demo.</p>
<p>If you do download the example please comment and give feedback as i want to make my blog&#8217;s as useful as possible for everyone. If you need any more info or help just ask! I always have time for people if you are keen to learn <img src='http://blog.didsburydesign.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Please comment on the article and if you like it link back to me and digg it!</p>
<p>All feedback welcome, thank you</p>
<p>If you would like to download a basic example then please do so <a title="Example Files" href="http://www.andigibson.co.uk/demo/lang/AndiGibson-languageDemo.zip" target="_blank"><strong>here</strong></a></p>
<p>If you would like to view the online demo go <a title="Online Demo" href="http://www.andigibson.co.uk/demo/lang/index.php" target="_blank"><strong>here</strong></a></p>
<p>If you are interested in learning more about PHP we highly recommend this book and it will really help you with your development:</p>
<p><iframe src="http://rcm-uk.amazon.co.uk/e/cm?t=social08-21&#038;o=2&#038;p=8&#038;l=as1&#038;asins=1590598199&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.didsburydesign.com/2009/04/how-to-make-a-website-that-allows-for-multiple-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

