<?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>tclayson</title>
	<atom:link href="http://tclayson.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tclayson.com</link>
	<description>Developer&#039;s tips and tricks and interesting news</description>
	<lastBuildDate>Sun, 07 Oct 2012 18:47:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
		<item>
		<title>three.js, 3d webGL and animation</title>
		<link>http://tclayson.com/2012/09/28/three-js-3d-webgl-and-animation/</link>
		<comments>http://tclayson.com/2012/09/28/three-js-3d-webgl-and-animation/#comments</comments>
		<pubDate>Fri, 28 Sep 2012 14:25:28 +0000</pubDate>
		<dc:creator>tclayson</dc:creator>
				<category><![CDATA[3d]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://tclayson.com/?p=89</guid>
		<description><![CDATA[This is a cool 3d modelling and animation library with some cool examples such as these birds: Mr Doob Canvas Geometry Birds It seems pretty cool, time to get into browser based 3d. See more examples and download three.js at Three.js Github]]></description>
			<content:encoded><![CDATA[<p>This is a cool 3d modelling and animation library with some cool examples such as these birds: <a href="http://mrdoob.github.com/three.js/examples/canvas_geometry_birds.html">Mr Doob Canvas Geometry Birds</a></p>
<p>It seems pretty cool, time to get into browser based 3d.</p>
<p><a href="http://tclayson.com/wp-content/uploads/2012/09/Screen-Shot-2012-09-28-at-15.20.30.png"><img src="http://tclayson.com/wp-content/uploads/2012/09/Screen-Shot-2012-09-28-at-15.20.30.png" alt="" title="Screen Shot 2012-09-28 at 15.20.30" width="480" height="360" class="alignnone size-full wp-image-91" /></a></p>
<p>See more examples and download three.js at <a href="http://mrdoob.github.com/three.js/">Three.js Github</a></p>
]]></content:encoded>
			<wfw:commentRss>http://tclayson.com/2012/09/28/three-js-3d-webgl-and-animation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple MY_Model class for all models in Codeigniter</title>
		<link>http://tclayson.com/2012/07/10/simple-my_model-class-for-all-models-in-codeigniter/</link>
		<comments>http://tclayson.com/2012/07/10/simple-my_model-class-for-all-models-in-codeigniter/#comments</comments>
		<pubDate>Tue, 10 Jul 2012 11:24:59 +0000</pubDate>
		<dc:creator>tclayson</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://tclayson.com/?p=85</guid>
		<description><![CDATA[Codeigniter&#8217;s model structure is a bit complicated and doesn&#8217;t quite work in the ways you would think it should. However, I have extended the default model class to include some helpful functions which should be available to all models. It is by far the easiest and most comfortable way to use models in Codeigniter that [...]]]></description>
			<content:encoded><![CDATA[<p>Codeigniter&#8217;s model structure is a bit complicated and doesn&#8217;t quite work in the ways you would think it should.</p>
<p>However, I have extended the default model class to include some helpful functions which should be available to all models. It is by far the easiest and most comfortable way to use models in Codeigniter that I&#8217;ve found so far.</p>
<p>Here is the code. Feel free to extend and edit as you feel. Let me know how you get on.</p>
<p>Put this in <code>application/core/MY_Model.php</code></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> MY_Model <span style="color: #000000; font-weight: bold;">extends</span> CI_Model <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$table</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$obj</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// insert a row - pass in an object to $o and it will insert</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> insert<span style="color: #009900;">&#40;</span><span style="color: #000088;">$o</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #339933;">,</span> <span style="color: #000088;">$o</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insert_id</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.id&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">obj</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">row</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// update - set the model's obj variable to be the updated object</span>
        <span style="color: #666666; font-style: italic;">// then run this function. Assumes your primary key column is id</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">obj</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">obj</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// get all the records with where clause if necessary</span>
        <span style="color: #666666; font-style: italic;">// returns array of objects</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> get_all<span style="color: #009900;">&#40;</span><span style="color: #000088;">$where</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$where</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$where</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">result</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// get a single record with where clause if necessary</span>
        <span style="color: #666666; font-style: italic;">// returns object</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> get<span style="color: #009900;">&#40;</span><span style="color: #000088;">$where</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$where</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$where</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">row</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now you can extend and set the $table variable in your constructor.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Table_model <span style="color: #000000; font-weight: bold;">extends</span> MY_Model <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;tblTable&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This means you get all the default <code>get()</code>, <code>get_all()</code> and <code>insert</code>, <code>update</code> functions out of the box, with no need to replicate code.</p>
]]></content:encoded>
			<wfw:commentRss>http://tclayson.com/2012/07/10/simple-my_model-class-for-all-models-in-codeigniter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple layouts/template system for Codeigniter</title>
		<link>http://tclayson.com/2012/07/04/simple-layoutstemplate-system-for-codeigniter/</link>
		<comments>http://tclayson.com/2012/07/04/simple-layoutstemplate-system-for-codeigniter/#comments</comments>
		<pubDate>Wed, 04 Jul 2012 11:22:14 +0000</pubDate>
		<dc:creator>tclayson</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://tclayson.com/?p=83</guid>
		<description><![CDATA[Codeigniter comes with a nice way of dealing with views and such as part of its MVC structure. However, it gets a bit more complicated when you want to replicate layouts, for instance if you have a header and footer, and don&#8217;t want to have to copy the code for this into lots of different [...]]]></description>
			<content:encoded><![CDATA[<p>Codeigniter comes with a nice way of dealing with views and such as part of its MVC structure.</p>
<p>However, it gets a bit more complicated when you want to replicate layouts, for instance if you have a header and footer, and don&#8217;t want to have to copy the code for this into lots of different views. After a couple of different views it gets pretty complicated and not very manageable.</p>
<p>So I&#8217;ve come up with a simple layouts/template system to work with Codeigniter in order to help alleviate some of the issues. You&#8217;re free to use this as you want.</p>
<p>Basically I&#8217;ve extended the controller class to include a couple more methods. Copy this into a file called <code>MY_Controller.php</code> in <code>application/core/</code>.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> MY_Controller <span style="color: #000000; font-weight: bold;">extends</span> CI_Controller <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$content_areas</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><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;">function</span> add_view<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content_area</span><span style="color: #339933;">,</span> <span style="color: #000088;">$view</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_content</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$content_area</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$view</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><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;">function</span> add_content<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content_area</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">content_areas</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$content_area</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$content</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> render<span style="color: #009900;">&#40;</span><span style="color: #000088;">$layout</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;default&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'layouts/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$layout</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">content_areas</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The idea is that you create &#8220;layouts&#8221;, and within these layouts you can define &#8220;content areas&#8221; and fill those content areas with either generated content, or with views you have created.</p>
<p>Go ahead and create a file called <code>default.php</code> in <code>application/views/layouts/</code>. It can look like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
    &lt;head&gt;
        &lt;!-- this is the first &quot;content area&quot; called &quot;page_title&quot; --&gt;
        &lt;title&gt;&lt;?=$page_title?&gt;&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;h1&gt;My Website Layout&lt;/h1&gt;
        &lt;div class=&quot;content&quot;&gt;
            &lt;!-- this is the second content area, just called &quot;main&quot; --&gt;
            &lt;?=$main?&gt;
        &lt;/div&gt;
    &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>And create a view called <code>homepage.php</code> in <code>application/views/</code>. It can look something like this:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="html" style="font-family:monospace;">Hello World. &lt;button&gt;Here is a button&lt;/button&gt;</pre></td></tr></table></div>

<p>Now you need to create a controller which extends <code>MY_Controller</code>:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Homepage <span style="color: #000000; font-weight: bold;">extends</span> MY_Controller</pre></td></tr></table></div>

<p>&#8230; and put this code in the <code>index()</code> function:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;text&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&quot;optional data variable if wanted for the views&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;main&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;homepage&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// put the &quot;homepage&quot; view in the &quot;main&quot; content area, passing in the $data array if wanted</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">add_content</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;page_title&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Welcome to my website&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// pass in the standard text content</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// render the page with the layout and the content</span></pre></td></tr></table></div>

<p>How you should be able to go to <code>http://yourwebsite.com/index.php/homepage</code> and see the layout, view and content rendered correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://tclayson.com/2012/07/04/simple-layoutstemplate-system-for-codeigniter/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Custom WP_Query and loop with pagination &#8211; without plugins</title>
		<link>http://tclayson.com/2012/03/28/custom-wp_query-and-loop-with-pagination-without-plugins/</link>
		<comments>http://tclayson.com/2012/03/28/custom-wp_query-and-loop-with-pagination-without-plugins/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 10:56:30 +0000</pubDate>
		<dc:creator>tclayson</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[custom loop]]></category>
		<category><![CDATA[custom post type]]></category>
		<category><![CDATA[custom query]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[paging]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress loop]]></category>
		<category><![CDATA[wp_query]]></category>

		<guid isPermaLink="false">http://tclayson.com/?p=74</guid>
		<description><![CDATA[This is very easy to do, and yet is so difficult to find info on around the net. Follow this guide to build functional custom WP_Querys and loops with the correct pagination using WordPress&#8217; built in functions. Firstly you need to define your WP_Query. Importantly you don&#8217;t want to use the $wp_query variable. This may [...]]]></description>
			<content:encoded><![CDATA[<p>This is very easy to do, and yet is so difficult to find info on around the net. Follow this guide to build functional custom WP_Querys and loops with the correct pagination using WordPress&#8217; built in functions.</p>
<p>Firstly you need to define your WP_Query. Importantly you don&#8217;t want to use the <strong>$wp_query</strong> variable. This may mess up other queries around the site (especially if you&#8217;re doing this in a template page and you&#8217;re using plugins). So, use another variable. Lets say you want to get all posts under the custom post type <code>global_news</code>.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
	<span style="color: #000088;">$global_posts_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span>
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'posts_per_page'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'paged'</span> <span style="color: #339933;">=&gt;</span> get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'paged'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'global_news'</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$global_posts_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;ul&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$global_posts_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$global_posts_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;li&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/li&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span>
		<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/ul&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;div class=&quot;navigation&quot;&gt;
	&lt;div class=&quot;next-posts&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> next_posts_link<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;laquo; Older Entries'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$global_posts_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_num_pages</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
	&lt;div class=&quot;prev-posts&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> previous_posts_link<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Newer Entries &amp;raquo;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$global_posts_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_num_pages</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>Ok, great, let me explain. The first block:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$global_posts_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span>
		<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'posts_per_page'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'paged'</span> <span style="color: #339933;">=&gt;</span> get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'paged'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'global_news'</span>
		<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This sets up the <code>WP_Query</code>. If you <a href="http://codex.wordpress.org/Class_Reference/WP_Query">look at the reference</a> for <code>WP_Query</code> you will see a list of parameters that <code>WP_Query</code> accepts. You can modify most things about the query, and actually set up some complicated filtering if you need to. For now we&#8217;re just using the three simple parameters:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #0000ff;">'posts_per_page'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">10</span></pre></td></tr></table></div>

<p>This tells the query how many posts to get per page. Lets say you have 24 posts altogether: on the first page there will be 10 posts, on the second page there will be 10 posts and (because there are 4 posts left over) on the third page there will be the remaining 4 posts.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #0000ff;">'paged'</span> <span style="color: #339933;">=&gt;</span> get_query_var<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'paged'</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>WordPress features a built in pagination system which appends <code>/page/1</code> or <code>?page=1</code> style suffixes to your current url (depending on your permalink settings). This line of code will make sure that that value is parsed and passed into the <code>WP_Query</code>. So if you&#8217;re on page 2, you get the second lot of results.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #0000ff;">'post_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'global_news'</span></pre></td></tr></table></div>

<p>This last bit is just for our example. This gets posts which are of the custom post type <code>global_news</code>. For more information on custom post types see <a href="http://codex.wordpress.org/Post_Types">the reference</a>.</p>
<p>The next section is the loop. Again, this should be quite self explanatory, especially if you&#8217;ve done any programming with WordPress before. The main thing to note is the use of the <code>$global_posts_query</code> variable we used before. Because we&#8217;ve created a custom <code>WP_Query</code> in a separate variable (not <code>$wp_query</code>) the standard <code>have_posts()</code> and <code>the_post()</code> won&#8217;t work. They need to be prefixed with our custom variable.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">	if($global_posts_query-&gt;have_posts()) :
&nbsp;
		echo &quot;&lt;ul&gt;&quot;;
&nbsp;
		while($global_posts_query-&gt;have_posts()) : $global_posts_query-&gt;the_post();
		?&gt;
			&lt;li&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/li&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span>
		<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/ul&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>So we&#8217;re testing to see if we have posts. Then we set up an unordered list to display a list of the titles. Then we set up the loop. Again, note the use of the prefixed custom query variable. Once we have run <code>$global_posts_query->the_post();</code> however we can now use the standard functions (e.g. <code>the_title();</code> and <code>the_content();</code> as we have set up a custom loop. This will <strong>only</strong> work within the while loop however.</p>
<p>Then its just a matter of outputting the title into a list item, ending the while loop, unordered list and then the if statement.</p>
<p>The last section is where we set up the links to go backwards and forwards through the list of posts.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">&lt;div class=&quot;navigation&quot;&gt;
	&lt;div class=&quot;next-posts&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> next_posts_link<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;laquo; Older Entries'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$global_posts_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_num_pages</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
	&lt;div class=&quot;prev-posts&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> previous_posts_link<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Newer Entries &amp;raquo;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$global_posts_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">max_num_pages</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>The functions <code>next_posts_link()</code> and <code>previous_posts_link()</code> will output anchors with the text you set as the first argument which use WordPress&#8217; <code>/page/1</code> or <code>?page=1</code> URL vars we discussed earlier.</p>
<p>Due to the fact we have set up a custom <code>WP_Query</code> with our own variable name (<code>$global_posts_query</code>) we need to pass the <code>max_num_pages</code> variable of our custom post as the second argument (or else the correct links won&#8217;t display at all!).</p>
<p>If you put all this code together and place it in a template file in your theme then you should get the correct output of a list of titles of custom posts and the appropriate backwards and forwards links to go with it.</p>
<p>You can also use plugins like <a href="http://wordpress.org/extend/plugins/wp-pagenavi/">WP_Pagenavi</a> to change the standard back and forwards links to have much more functionality, such as a page count and links to specific pages, such as you see on a Google search listing.</p>
<p>Let me know how you get on!</p>
]]></content:encoded>
			<wfw:commentRss>http://tclayson.com/2012/03/28/custom-wp_query-and-loop-with-pagination-without-plugins/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How To Fix Error: &#8220;Warning: session_start() [function.session-start]: open(/path/to/file, O_RDWR) failed: Permission denied (13) in /path/to/script.php on line __LINE__&#8221;</title>
		<link>http://tclayson.com/2012/03/08/how-to-fix-error-warning-session_start-function-session-start-openpathtofile-o_rdwr-failed-permission-denied-13-in-pathtoscript-php-on-line-__line__-2/</link>
		<comments>http://tclayson.com/2012/03/08/how-to-fix-error-warning-session_start-function-session-start-openpathtofile-o_rdwr-failed-permission-denied-13-in-pathtoscript-php-on-line-__line__-2/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 16:23:33 +0000</pubDate>
		<dc:creator>tclayson</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[sessions]]></category>
		<category><![CDATA[session_start]]></category>

		<guid isPermaLink="false">http://tclayson.com/?p=71</guid>
		<description><![CDATA[I recently had this error. There was lots of information on the internet, but nothing that could help me with my specific case. It would appear that a session file is not accessible anymore and this is causing the error. Aside from the error itself, I was only seeing this error on one particular browser [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had this error. There was lots of information on the internet, but nothing that could help me with my specific case. It would appear that a session file is not accessible anymore and this is causing the error. Aside from the error itself, I was only seeing this error on one particular browser on one particular computer and could not replicate anywhere else.</p>
<p>The fix I found was to remove the session file at the location defined in <code>open(/path/to/file, O_RDWR)</code>. To do this you need to SSH into your server. If you don&#8217;t have access to your server via SSH then you should probably submit a support ticket with your hosting company explaining which file you need removed and they&#8217;ll be able to do this for you.</p>
<p>Open terminal (or equivalent, I&#8217;m on a Mac) and SSH to your web server:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">ssh</span> username<span style="color: #000000; font-weight: bold;">@</span>server.com</pre></td></tr></table></div>

<p>And just remove the file. You could use <code>sudo rm</code> but you&#8217;re probably better off just renaming the file incase you need it again.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span>file.backup</pre></td></tr></table></div>

<p>This should clear up the error for you. I hope this helps someone else.</p>
]]></content:encoded>
			<wfw:commentRss>http://tclayson.com/2012/03/08/how-to-fix-error-warning-session_start-function-session-start-openpathtofile-o_rdwr-failed-permission-denied-13-in-pathtoscript-php-on-line-__line__-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>600 Windows Metro Icons Worth £320 For Free!</title>
		<link>http://tclayson.com/2012/03/07/600-windows-metro-icons-worth-320-for-free/</link>
		<comments>http://tclayson.com/2012/03/07/600-windows-metro-icons-worth-320-for-free/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 13:33:23 +0000</pubDate>
		<dc:creator>tclayson</dc:creator>
				<category><![CDATA[Metro]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[free software]]></category>
		<category><![CDATA[freeware]]></category>
		<category><![CDATA[metro icons]]></category>
		<category><![CDATA[metro ui]]></category>
		<category><![CDATA[mobile devlopment]]></category>
		<category><![CDATA[windows development]]></category>
		<category><![CDATA[windows metro]]></category>

		<guid isPermaLink="false">http://tclayson.com/?p=57</guid>
		<description><![CDATA[Syncfusion are currently offering their &#8220;Metro Studio 1&#8243;, which features 600+ royalty free Windows Metro-style icons for free. It has a face value of $499 (~£320), so is a steal for nothing. Syncfusion do not state whether this is a time limited offer, although all the information would point to it being a permanent offer. [...]]]></description>
			<content:encoded><![CDATA[<p>Syncfusion are currently offering their &#8220;Metro Studio 1&#8243;, which features 600+ royalty free Windows Metro-style icons for free. It has a face value of $499 (~£320), so is a steal for nothing.</p>
<p><img src="http://tclayson.com/wp-content/uploads/2012/03/Screen-Shot-2012-03-07-at-13.15.00.png" alt="" title="Screen Shot 2012-03-07 at 13.15.00" width="480" height="350" class="alignnone size-full wp-image-58" /></p>
<p>Syncfusion do not state whether this is a time limited offer, although all the information would point to it being a permanent offer. Syncfusion have noted on their FAQ:</p>
<blockquote><p><em>It&#8217;s our 10th year in business and this is just our way of giving back to the development community. Additionally, as a developer of .NET components we have every incentive to stay in touch with developers.</em></p></blockquote>
<p>As a Windows application I haven&#8217;t had a chance to test out the program yet, but reviews seem to point to the fact that this is an exceptionally useful and brilliant program.</p>
<p>Syncfusion are actively developing the range of icons, so it is definitely worth the space on your hard drive. On their website they state, <em>&#8220;&#8230; we plan to create hundreds or even thousands more so keep the requests coming.&#8221;</em>.</p>
<p>Metro UI is a Windows&#8217; led realisation of Microsofts new Metro Design Language and features a tile-based interface with distintive block-colour, 2d icons. At the time of writing it is currently featured in Windows Mobile 7 and Windows 8.</p>
<p><a href="http://www.syncfusion.com/downloads/metrostudio">Download Syncfusion&#8217;s Metro Studio 1 here.</a> If you have downloaded it, tell me what you think of it in the comments, or <a href="http://twitter.com/tclayson">tweet me</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://tclayson.com/2012/03/07/600-windows-metro-icons-worth-320-for-free/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Informal review of my new Macbook Air</title>
		<link>http://tclayson.com/2012/03/05/informal-review-of-my-new-macbook-air/</link>
		<comments>http://tclayson.com/2012/03/05/informal-review-of-my-new-macbook-air/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 22:04:43 +0000</pubDate>
		<dc:creator>tclayson</dc:creator>
				<category><![CDATA[Apple]]></category>

		<guid isPermaLink="false">http://tclayson.com/?p=53</guid>
		<description><![CDATA[I&#8217;ve just bought myself a brand new Macbook Air. I went for the 13&#8243; model with 4GB RAM, 1.7Ghz i5 and 128GB SSD (or, as the guy in the shop so eloquently put it &#8220;the entry level model&#8221;!!!). Its the best thing to ever happen to me (with the notable exception of all the other [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just bought myself a brand new Macbook Air. I went for the 13&#8243; model with 4GB RAM, 1.7Ghz i5 and 128GB SSD (or, as the guy in the shop so eloquently put it &#8220;the <strong>entry level</strong> model&#8221;!!!). Its the best thing to ever happen to me (with the notable exception of all the other things that should probably come above a laptop, like my family and my girlfriend &#8211; they&#8217;re definitely better &#8211; no question).</p>
<p>I was a bit hesitant to tell the truth. Its not every day I spend huge amounts of money on something and the little niggles set in as I made my way to the <a href="https://www.krcs.co.uk/pages/home">KRCS</a> shop (our version of an Apple shop). Realistically I&#8217;d have liked a Macbook Pro. They&#8217;re superior in every way, and I&#8217;m really a tech spec&#8217;s kinda person &#8211; the more RAM, Ghz and GB something has the better. I&#8217;m a sucker for a high number. But also I realised that I wouldn&#8217;t have the money to buy myself a top of the range MBP (if you&#8217;re going to spend a huge amount you might as well go all out and get the top spec model&#8230; right?), and also, one of the main complaints I have with my Dell 17&#8243; Studio laptop is that it is so heavy, after a few hours with it in a shoulder strap bag I&#8217;m in excruciating pain.</p>
<p>So I turned my attentions to the Macbook Air. Falling in love with it wasn&#8217;t difficult. Its a think of beauty. A physiological phenomenon. However beauty very rarely wins me over in matters of such importance.</p>
<p>My main issues were the spec of the machine. You only get a choice between 128GB and 256GB, and the processor speed is a poultry 1.7Ghz i5 (or a 1.8Ghz i7 if you buy the 256GB version and choose to upgrade at great expense). This thing has the spec of a smart phone! There was no way it would reliably run XCode. It would have no chance compiling Android apps&#8230; surely?</p>
<p>How wrong I was. </p>
<p>I bit the bullet and bought the machine. I had done a great lot of research into its capabilities as a development machine and had read many reviews and discussions on the internet regarding how well it worked with XCode and Eclipse, as well as the general performance of it.</p>
<p>I opted for the 13&#8243; version. As a developer I&#8217;m very keen to monopolise on screen real estate. I must say that the new spaces with OSX Lion has helped with a lot of the issues with having a small screen, but I still wanted something that I would be able to use appropriately, that wouldn&#8217;t cause overcrowding, or cause IDEs to only be able to display a few lines of code at a time. The 13&#8243; model has the screen resolution of a 15&#8243; Macbook Pro and I must say it fits a hell of a lot into it, very concisely and with no impact on visibility at all. Text is crisp and legible, colours shine through the wafer-thin screen as vibrantly as they do on my iMac. The screen never feels small.</p>
<p>To say that I don&#8217;t notice any performance loss is a complete understatement. In fact in many ways (presumably thanks to the SSD) my Macbook Air is much faster than my iMac at many tasks. Startup, loading programs and all sorts takes mere seconds compared to the long waiting times (e.g. opening Photoshop and booting) I experience on my iMac. OSX Lion runs smoothly and capably without any signs of a &#8220;slow&#8221; processor, as do all the programs I&#8217;m running, XCode, Eclipse, Coda and more. Multitasking is also smooth as hell. Although I haven&#8217;t tested it to full capacity it has no problem running Chrome with large numbers of tabs, Mail, iCal, twitter, XCode, Coda, Eclipse all at the same time. I&#8217;m sure there will be times when the processing power of my iMac will prove visibly better, but for my normal day to day needs I have no complaints.</p>
<p>My only worry is the size of the hard drive. I&#8217;m not one to put movies onto my laptop, nor will I use it to store photos or music (I have my iMac for that) however as I opted for the 128GB model I am wary that I don&#8217;t have that much space to mess around with. Applications that I don&#8217;t use come off as soon as I realise I&#8217;m not using them, and files I don&#8217;t use are deleted. I will probably learn to relax as time goes on, but its an issue that&#8217;s always at the back of my mind. </p>
<p>Overall I couldn&#8217;t be happer with my purchase. I&#8217;ve got a light machine, that beautifully sleek and impossibly thin. Its portable enough to be taken anywhere, but also durable and powerful enough to be used as I would any laptop or computer. Apple have thought of everything, even allowing my iMac to &#8220;share&#8221; its CD/DVD drive wirelessly with the Air, should I need to (although I can&#8217;t remember if I have ever even used the optical drive on my iMac for &#8220;reading&#8221; &#8211; I&#8217;ve probably burnt a few discs).</p>
<p>I would recommend a Macbook Air to anyone who is thinking of buying a new Apple laptop. Realistically there isn&#8217;t much that this little piece of magic can&#8217;t do that a Macbook Pro can, and it can do it all looking beautiful, and not denting your wallet, or breaking your shoulder!</p>
]]></content:encoded>
			<wfw:commentRss>http://tclayson.com/2012/03/05/informal-review-of-my-new-macbook-air/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>50GB Free Storage with Box.net and Android</title>
		<link>http://tclayson.com/2012/02/24/50gb-free-storage-with-box-net-and-android/</link>
		<comments>http://tclayson.com/2012/02/24/50gb-free-storage-with-box-net-and-android/#comments</comments>
		<pubDate>Fri, 24 Feb 2012 10:52:12 +0000</pubDate>
		<dc:creator>tclayson</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Android Apps]]></category>
		<category><![CDATA[50GB]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[box]]></category>
		<category><![CDATA[box.net]]></category>
		<category><![CDATA[cloud storage]]></category>
		<category><![CDATA[cross platform]]></category>
		<category><![CDATA[dropbox]]></category>
		<category><![CDATA[free storage]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://tclayson.com/?p=45</guid>
		<description><![CDATA[Box, the main competitor to Dropbox and my favourite personal cloud storage service, is currently giving away 50GB with their updated Android app as long as you register and sign in on the Android app before March 24th. You also get a file size bump up to 100MB from 25MB. This is an offer Box [...]]]></description>
			<content:encoded><![CDATA[<p>Box, the main competitor to Dropbox and my favourite personal cloud storage service, is currently giving away 50GB with their updated Android app as long as you register and sign in on the Android app before March 24th. You also get a file size bump up to 100MB from 25MB.</p>
<p>This is an offer Box have offered before with the <a href="http://reviews.cnet.com/8301-19512_7-20120674-233/get-50gb-of-free-cloud-storage-with-box.net-for-ios/">iPhone</a> and the <a href="http://www.opinionless.com/the-hp-touchpads-free-50gb-box-net-storage-account/">HP Touchpad</a>. I received my 50GB free when I bought my HP Touchpad in the fire sale last year, and it&#8217;s brilliantly useful, offering a well designed app, cross platform compatibility, a web site for all situations and all the features that you get with Dropbox.</p>
<p>Plus, if you want to get into your friends&#8217; good books you can give them all 50GB for free too. For this to work you must have your own domain name and be able to set up mail accounts on that domain. Change the main email address on your Box account to one @ your domain. Set your friends up with temporary mail accounts @ your domain too. When you&#8217;ve received your free 50GB you should see a link in the web control panel to give 50GB to your co-workers. Click this and fill out the form. Use the temporary emails you set up for your mates (so it looks like you all work at the same company). Once they&#8217;ve signed up using your temporary email addresses the can change their account email back to their personal email address and you can remove the temporary email address from your domain name.</p>
<p>Just to reiterate, in order to get the 50GB free you need to register (where you register doesn&#8217;t matter) then you need to download the Android app and sign in before the deadline (March 24th). The part which is important is the signing in to the app part. If you register and put off downloading the Android app and signing in till after the deadline you will not receive your 50GB free.</p>
]]></content:encoded>
			<wfw:commentRss>http://tclayson.com/2012/02/24/50gb-free-storage-with-box-net-and-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Word Documents on the fly, on any platform, using HTML and CSS</title>
		<link>http://tclayson.com/2012/02/23/creating-word-documents-on-the-fly-on-any-platform-using-html-and-css/</link>
		<comments>http://tclayson.com/2012/02/23/creating-word-documents-on-the-fly-on-any-platform-using-html-and-css/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 10:45:41 +0000</pubDate>
		<dc:creator>tclayson</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[cross platform]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[document]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[word]]></category>

		<guid isPermaLink="false">http://tclayson.com/?p=42</guid>
		<description><![CDATA[This is something I&#8217;ve come across a few times, and something I&#8217;ve had a few people ask me from time to time. Unless you&#8217;re using C#, and/or want a huge headache, this is probably your best option, and works very effectively. The trick is to use HTML, CSS, save the file with a .doc extension [...]]]></description>
			<content:encoded><![CDATA[<p>This is something I&#8217;ve come across a few times, and something I&#8217;ve had a few people ask me from time to time. Unless you&#8217;re using C#, and/or want a huge headache, this is probably your best option, and works very effectively.</p>
<p>The trick is to use HTML, CSS, save the file with a <code>.doc</code> extension and add a tiny bit of custom code to force Page View in Microsoft Word.</p>
<p>Here&#8217;s the code you want:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;  &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html xmlns:v=&quot;urn:schemas-microsoft-com:vml&quot; 
    xmlns:o=&quot;urn:schemas-microsoft-com:office:office&quot; 
    xmlns:w=&quot;urn:schemas-microsoft-com:office:word&quot; 
    xmlns=&quot;http://www.w3.org/TR/REC-html40&quot;&gt;
&nbsp;
  &lt;head&gt;
    &lt;title&gt;Word Document&lt;/title&gt;
&nbsp;
    &lt;!-- This will force Page View in Word versions that support it --&gt;
    &lt;!--[if gte mso 9]&gt;
      &lt;xml&gt; 
        &lt;w:WordDocument&gt; 
          &lt;w:View&gt;Print&lt;/w:View&gt; 
          &lt;w:Zoom&gt;100&lt;/w:Zoom&gt; 
        &lt;/w:WordDocument&gt; 
      &lt;/xml&gt;
    &lt;![endif]--&gt; 
&nbsp;
    &lt;!-- CSS styles will work fine --&gt;
    &lt;style type=&quot;text/css&quot;&gt;
      body {
        font-family: Georgia, serif;
      }
      table {
        border: 4px solid #4c4c4c;
        background: red;
      }
      img {
        float: left;
      }
    &lt;/style&gt;
  &lt;/head&gt;
&nbsp;
  &lt;body&gt;
    &lt;table&gt;
      &lt;tr&gt;
        &lt;td&gt;This is a table with some text. This should be working fine.&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;
&nbsp;
    &lt;!-- Paragraphs will also work fine, as will floated elements like imgs - although beware,
         copy images and other external resources into the directory of your Word document
         as Word is not guaranteed to remotely fetch your images and such. --&gt;
    &lt;p&gt;&lt;img src=&quot;myimage.jpg&quot;&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur quam tellus, blandit a commodo eget, consequat ac risus. Cras laoreet porttitor nisi. Etiam tempor, quam vitae lobortis condimentum, urna quam vestibulum turpis, ac dignissim sapien orci et lectus. Nunc cursus eros id lorem suscipit ornare. Sed eu imperdiet arcu. Nulla nec pharetra nunc. Phasellus iaculis sodales leo, quis ultricies est vehicula eu. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Cras posuere, mi ut commodo lobortis, eros lorem aliquam urna, sed iaculis lacus orci non neque. Aliquam eu sem nisi.&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>I would probably stick to standard layouts, and not do anything too fancy as you can&#8217;t guarantee compatibility. Remember Word is NOT a browser.</p>
<p>Just save your HTML document with a <code>.doc</code> extension and you&#8217;re good to go. If you&#8217;re building this server side using PHP (or any other language, the example is transferable to other languages) you can also set the headers to force the file to download as a <code>.doc</code> document like so:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: application/vnd.ms-word&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Disposition: attachment; Filename=YourDocument.doc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://tclayson.com/2012/02/23/creating-word-documents-on-the-fly-on-any-platform-using-html-and-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Tricks: Clear floated elements</title>
		<link>http://tclayson.com/2012/02/22/css-tricks-clear-floated-elements/</link>
		<comments>http://tclayson.com/2012/02/22/css-tricks-clear-floated-elements/#comments</comments>
		<pubDate>Wed, 22 Feb 2012 22:55:52 +0000</pubDate>
		<dc:creator>tclayson</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://tclayson.com/?p=28</guid>
		<description><![CDATA[This is my favourite CSS trick at the moment. Floated elements are so useful, however, they also cause so much annoyance when you have to find ways of clearing them to allow content to start properly further down the page. Normally I would create a new element below the floated elements which would clear the [...]]]></description>
			<content:encoded><![CDATA[<p>This is my favourite CSS trick at the moment. Floated elements are so useful, however, they also cause so much annoyance when you have to find ways of clearing them to allow content to start properly further down the page.</p>
<p>Normally I would create a new element below the floated elements which would clear the elements ready for what was coming next:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="html" style="font-family:monospace;">&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="code"><pre class="html" style="font-family:monospace;">&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;</pre></td></tr></table></div>

<p>However, the whole point of CSS is that you are removing the style from the layout, and this particular &#8220;fix&#8221; for the issue of floated elements has always annoyed me. It was the only way to get around the issue, however never conformed to the CSS/HTML divide.</p>
<p>The workaround is to use CSS&#8217;s <code>:after</code> pseudo class. This effectively lets you select the area immediately at the end of the element you&#8217;re referencing. Contrary to the definition <code>:after</code> actually behaves like jQuery&#8217;s <code>append()</code> function. As such be wary to apply the <code>:after</code> to the parent element which contains your floated elements.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;container&quot;&gt;
  &lt;div class=&quot;left_col&quot;&gt;
    Left Column&lt;br /&gt;
    Left Column&lt;br /&gt;
    Left Column
  &lt;/div&gt;
  &lt;div class=&quot;right_col&quot;&gt;
    Right Col&lt;br /&gt;
    Right Col&lt;br /&gt;
    Right Col
  &lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* 
 * set the container bg colour
 * so that you can see the effect
 */</span>
<span style="color: #6666ff;">.container</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">red</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">white</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.left_col</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.right_col</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/*
 * here is where the magic happens
 * we use the :after pseudo class
 * to append some content to the
 * .container element. We then set
 * that appended content to display
 * as a block and clear: both.
 * We use visibility: hiddden because
 * we are using display: block and as
 * such we will have to set the height
 * to 0 to make sure no space is taken
 * up
 */</span>
<span style="color: #6666ff;">.container</span><span style="color: #3333ff;">:after </span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">both</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">'.'</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">visibility</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Here is a <a href="http://jsfiddle.net/tclayson/VFcUv/" target="_blank">jsfiddle</a> to display the difference. Feel free to play around with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://tclayson.com/2012/02/22/css-tricks-clear-floated-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
