<?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>Flipflops.org &#187; Web Things</title>
	<atom:link href="http://www.flipflops.org/category/websites/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.flipflops.org</link>
	<description>Flipflops.org is about web development and fairly conceptual art</description>
	<lastBuildDate>Tue, 31 Jan 2012 23:26:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Speed matters</title>
		<link>http://www.flipflops.org/2012/01/13/speed-matters/</link>
		<comments>http://www.flipflops.org/2012/01/13/speed-matters/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 21:48:13 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[Web Things]]></category>
		<category><![CDATA[seo]]></category>
		<category><![CDATA[servers]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=411</guid>
		<description><![CDATA[To my unending amazement, many people I&#8217;ve worked with simply don&#8217;t believe that speed matters as a factor in Search Engine rankings. I don&#8217;t understand why. It&#8217;s not like Google (and lets face it, we are talking about Google) are being coy about it. (see links) When you work in an office with stupidly fast [...]]]></description>
			<content:encoded><![CDATA[<p>To my unending amazement, many people I&#8217;ve worked with simply don&#8217;t believe that speed matters as a factor in Search Engine rankings. I don&#8217;t understand why. It&#8217;s not like Google (and lets face it, we are talking about Google) are being coy about it. (see links)</p>
<p>When you work in an office with stupidly fast broadband, maybe you just forget? But you shouldn&#8217;t assume that the people looking at your websites do.</p>
<p>The bit that really bugs me is this peculiar &#8216;head in the sand&#8217; attitude. It does take more than a few minutes of thinking to come up with any number plausible reasons why speed is important for Search Engine Optimisation (aside from the fact the Google say it is). Try it, take a few seconds to think.</p>
<p>For me though the reasons that scream out at me are User Experience and Money.</p>
<h2>User experience</h2>
<p>First off &#8211; I admit this isn&#8217;t really an SEO factor, is it? People are busy, they don&#8217;t want to spend valuable time waiting for a web page to load, at least I know I don&#8217;t. I have better things to do, and I&#8217;m not that weird.</p>
<p>But why would Google care? I can rationalise that they want people to look at Ads. And then click on them.  Probably a good idea to make websites faster so people don&#8217;t get bored and do something else, or find the bit of content they are looking for before the ads have loaded (because the ads come last).</p>
<h2>Time = Money</h2>
<p>Google must index billions of pages per day. It stands to reason that the faster a site loads, the faster it can be indexed. I&#8217;m guessing that it costs about the same to run a server whether it is indexing million pages per day or 10 million &#8211; but if your business is based on data the faster you can chew through data the better &#8211; and therefore it also makes sense for Google to promote an internet that lets them index more, faster.</p>
<h2>But we don&#8217;t have the time, it&#8217;s to hard&#8230;</h2>
<p>No it isn&#8217;t. Of course, as with any work there is optimum point in terms of cost vs. benefit (and that will be different for every site).</p>
<p>My gut feeling (and I don&#8217;t have any firm evidence for this) is that speed becomes more important the more traffic you get. If you&#8217;re site gets 50 visitors per day, then in a sense it is what it is &#8211; what you need to focus on is link building and content. However if your site gets 5000 visitors per day, then the chances are you&#8217;ve got quality links and good content &#8211; so how do you improve? I think the answer is the speed and user experience.</p>
<p>A fast website either means no traffic, no load on your server, no pictures, no javascript &#8211; in short a bit of old school html text&#8230; or it if is a big site, it means you care. It means that you have taken the time to think about users, you&#8217;ve spent a bit of money on hardware or code. It means that you are a quality business and therefore it is a good bet that you have better quality data on your site. It means that people will pay more to be associated with your site.</p>
<h2>How to make your site fast</h2>
<p>Hell, that&#8217;s a bold statement. It&#8217;s different for everybody. Think about the usual suspects, too much JavaScript, un-optimised images, sloooow queries with no indexes.</p>
<p>There are a myriad of solutions, and you don&#8217;t have to have Prototype, Jquery and Mootools all running on the same page, choose a single framework at a time &#8211; you will be amazed.</p>
<ul>
<li>Use a CDN. </li>
<li>Use a cache server like <a href="https://www.varnish-cache.org/">Varnish</a>.</li>
<li>If you&#8217;re a bit lazy &#8211; try out <a href="http://code.google.com/speed/page-speed/docs/module.html">mod_pagespeed</a> (sometimes it&#8217;s fab, sometimes it&#8217;ll melt your server)</li>
<li>Be brave, leave the Apache comfort zone and use <a href="http://nginx.org/">Nginx</a> or <a href="http://www.lighttpd.net/">Lighttpd</a></li>
<li>Use <a href="http://code.google.com/p/minify/">minify</a></li>
</ul>
<h2>Fringe benefits</h2>
<p>Chances are you&#8217;ll end up using some kind of caching and you&#8217;ll start setting sensible expires headers for your static content. But just think you&#8217;ll never have to tell somebody at the end of the phone to clear their browser cache again. And remember, the client is not an idiot because their browser hasn&#8217;t magically detected that a style sheet or an image has changed, and the website they have paid for looks a bit rubbish.</p>
<p>(by the way I don&#8217;t always practice what I&#8217;ve just preached, but at least I feel bad about it)</p>
<p><a href="http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html">http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html</a><br />
<a href="http://www.mattcutts.com/blog/site-speed/">http://www.mattcutts.com/blog/site-speed/</a><br />
<a href="http://www.google.co.uk/search?sourceid=chrome&#038;ie=UTF-8&#038;q=google+speed+as+factor+in+search+engine+ranking" title="google speed as factor in search engine ranking">etc.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2012/01/13/speed-matters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick debug function</title>
		<link>http://www.flipflops.org/2011/06/13/quick-debug-function/</link>
		<comments>http://www.flipflops.org/2011/06/13/quick-debug-function/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 22:55:07 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Stuff]]></category>
		<category><![CDATA[Web Things]]></category>
		<category><![CDATA[debug]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=383</guid>
		<description><![CDATA[It&#8217;s not pretty and it&#8217;s not elegant, but we&#8217;ve all got a bag of quick and dirty functions that help make life just a little bit easier. This is a simple print_r() but I finally got fed up of loosing my quick debug statements and so added the line name and file number from a [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s not pretty and it&#8217;s not elegant, but we&#8217;ve all got a bag of quick and dirty functions that help make life just a little bit easier.</p>
<p>This is a simple <code>print_r()</code> but I finally got fed up of loosing my quick debug statements and so added the line name and file number from a stack trace (substitute var_export() to taste).</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> pr<span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;pre&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;/pre &gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> <span style="color: #990000;">debug_backtrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;br /&gt;Line: &lt;b&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$d</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'line'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/b&gt;'</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;hr /&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2011/06/13/quick-debug-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reorder a nested HTML list in PHP</title>
		<link>http://www.flipflops.org/2011/02/13/reorder-a-nested-html-list-in-php/</link>
		<comments>http://www.flipflops.org/2011/02/13/reorder-a-nested-html-list-in-php/#comments</comments>
		<pubDate>Sat, 12 Feb 2011 23:11:52 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Things]]></category>
		<category><![CDATA[simpleXML]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[XMLDom]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=374</guid>
		<description><![CDATA[Recently I was working on website where I had to re-order a nested list (part of a navigation menu) &#8211; unfortunately I only had access to fragment of HTML so I couldn&#8217;t just manipulate the arrays from which it was built. The menu was compiled from various arrays and months within years sometimes came out [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was working on website where I had to re-order a nested list (part of a navigation menu) &#8211; unfortunately I only had access to fragment of HTML so I couldn&#8217;t just manipulate the arrays from which it was built. The menu was compiled from various arrays and months within years sometimes came out all wrong.</p>
<p>So I thought, I&#8217;d just treat it as a bit of XML (which obviously it is) and re-order it using PHPs native XML handling classes. XML is one of those things that I use frequently, but never really do anything with, and finding a solution took me rather longer than I had expected. It is a mixture of simpleXML and XMLDom.</p>
<p>One of the main problems was the lack any real examples.</p>
<p>If anyone can suggest a more elegant solution, I would love to hear it.</p>
<p>Here is my code:</p>
<h3>The UL to re-order</h3>
<p>As you can see the month names are in the wrong order</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
16
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;ul id=&quot;menu&quot;&gt;
    &lt;li class=&quot;first&quot;&gt;&lt;a href=&quot;/news/q/date/2011/&quot;&gt;2011&lt;/a&gt;&lt;/li&gt;
    &lt;li class=&quot;current last&quot;&gt;
        &lt;a href=&quot;/news/q/date/2010/&quot;&gt;2010&lt;/a&gt;
            &lt;ul&gt;
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/07/&quot;&gt;July&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/06/&quot;&gt;June&lt;/a&gt;&lt;/li&gt;    
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/11/&quot;&gt;November&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot; last&quot;&gt;&lt;a href=&quot;/news/q/date/2010/10/&quot;&gt;October&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/09/&quot;&gt;September&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/08/&quot;&gt;August&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot;first&quot;&gt;&lt;a href=&quot;/news/q/date/2010/12/&quot;&gt;December&lt;/a&gt;&lt;/li&gt;
                &lt;li class=&quot;&quot;&gt;&lt;a href=&quot;/news/q/date/2010/05/&quot;&gt;May&lt;/a&gt;&lt;/li&gt;
           &lt;/ul&gt;
    &lt;/li&gt;
&lt;/ul&gt;</pre></td></tr></table></div>

<h3>My (woeful) solution</h3>

<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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// pull a node tree as an Array out using simpleXML xpath</span>
<span style="color: #000088;">$trees</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/ul/li/ul'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$array</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: #339933;">;</span>
<span style="color: #000088;">$order</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: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// we only need to delve into XML if there are any nested &lt;ul&gt;s</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;">$trees</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</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>
&nbsp;
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$trees</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$var</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// store each node in an indexed array</span>
		<span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$var</span><span style="color: #339933;">;</span> 
		<span style="color: #666666; font-style: italic;">// store the month number in an index array</span>
		<span style="color: #666666; font-style: italic;">// based on the text node value of the &lt;a&gt; tag</span>
		<span style="color: #000088;">$order</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'m'</span><span style="color: #339933;">,</span> <span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$var</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">a</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
		<span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// sort the month number array descending, but maintaining the keys</span>
	<span style="color: #990000;">arsort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
	<span style="color: #666666; font-style: italic;">// create a new XML Dom object to manipulate stuff</span>
	<span style="color: #000088;">$dom</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DomDocument<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// create a holder node &lt;ul&gt;</span>
	<span style="color: #000088;">$ul</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ul'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// iterate through the array of simpleXML objects </span>
	<span style="color: #666666; font-style: italic;">// based on the order in which their keys appear in the re-ordered array</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$order</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// get the simpleXML objects into a string</span>
		<span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dom_import_simplexml</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// get the string into an actual DOM node</span>
		<span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dom</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">importNode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// append</span>
		<span style="color: #000088;">$ul</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</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;">//$dom-&gt;appendChild($ul);</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// unset the contents of the original &lt;ul&gt; node that we have resorted</span>
	<span style="color: #000088;">$parent</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$trees</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">xpath</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parent::*'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$parent</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ul</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">NULL</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// turn our simpleXML object into a DOM object</span>
	<span style="color: #000088;">$ixml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dom_import_simplexml</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$new</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DOMDocument<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1.0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$ixml</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">importNode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ixml</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$ixml</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ixml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// fire up a DOM xpath object</span>
	<span style="color: #000088;">$xpath</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DomXpath<span style="color: #009900;">&#40;</span><span style="color: #000088;">$new</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">// pull a node tree out using simpleXML xpath</span>
	<span style="color: #000088;">$tree</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xpath</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/ul/li/ul'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// add our newly created DOM node conatining the re-ordered &lt;ul&gt; after the existing node</span>
	<span style="color: #000088;">$tree</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">appendChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">importNode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ul</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: #666666; font-style: italic;">// delete the original empty node</span>
	<span style="color: #000088;">$tree</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">removeChild</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tree</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</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: #000088;">$new</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveHTML</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2011/02/13/reorder-a-nested-html-list-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Mail &#8211; Priority Inbox</title>
		<link>http://www.flipflops.org/2010/09/05/google-mail-priority-inbox/</link>
		<comments>http://www.flipflops.org/2010/09/05/google-mail-priority-inbox/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 09:11:24 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Thoughtful]]></category>
		<category><![CDATA[Web Things]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=368</guid>
		<description><![CDATA[Awesome.]]></description>
			<content:encoded><![CDATA[<p>Awesome.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2010/09/05/google-mail-priority-inbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One of the reasons I never get to write anything here anymore&#8230;</title>
		<link>http://www.flipflops.org/2010/08/24/one-of-the-reasons-i-never-get-to-write-anything-here-anymore/</link>
		<comments>http://www.flipflops.org/2010/08/24/one-of-the-reasons-i-never-get-to-write-anything-here-anymore/#comments</comments>
		<pubDate>Tue, 24 Aug 2010 19:27:47 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Things]]></category>
		<category><![CDATA[pubs]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/?p=357</guid>
		<description><![CDATA[What with baby Tess, trying to move house and work, it&#8217;s scary how I simply never have the time to write anything here anymore, let alone anything that could possibly be useful to anybody else&#8230; Still I spend most of my time at work building this: So go on score your pint]]></description>
			<content:encoded><![CDATA[<p>What with baby Tess, trying to move house and work, it&#8217;s scary how I simply never have the time to write anything here anymore, let alone anything that could possibly be useful to anybody else&#8230;</p>
<p>Still I spend most of my time at work building this:</p>
<p><a href="http://www.useyourlocal.com"><img src="http://www.flipflops.org/wp-content/uploads/2010/08/uyl.jpg" alt="" title="UseYourLocal" width="500" height="378" class="alignleft size-full wp-image-358" /></a></p>
<div style="clear: both; margin-top: 20px;"></div>
<p>So go on <a href="http://www.useyourlocal.com/score-your-local/">score your pint</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2010/08/24/one-of-the-reasons-i-never-get-to-write-anything-here-anymore/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symbiotica</title>
		<link>http://www.flipflops.org/2009/09/24/symbiotica-2/</link>
		<comments>http://www.flipflops.org/2009/09/24/symbiotica-2/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 09:13:12 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Stuff]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Things]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/09/24/symbiotica-media-ltd/</guid>
		<description><![CDATA[I&#8217;ve been meaning to announce the launch of my company Symbiotica Media Ltd &#8211; based in Devon near the city of Exeter. As you will be unsurprised to learn it is a web development company &#8211; so if you need beautiful, functional websites and applications that are a joy to use, look no further. I [...]]]></description>
			<content:encoded><![CDATA[<p><a href='http://www.symbiotica.co.uk' title='Symbiotica Media Development Ltd - web design &#038; development in Devon'><img src='http://www.flipflops.org/wp-content/uploads/2009/08/logo.jpg' alt='Symbiotica Media Ltd - web design &#038; development in Devon' /></a></p>
<p>I&#8217;ve been meaning to announce the launch of my company <a href="http://blog.symbiotica.co.uk/2009/09/we-have-arrived/">Symbiotica Media Ltd</a> &#8211; based in Devon near the city of Exeter. As you will be unsurprised to learn it is a web development company &#8211; so if you need beautiful, functional websites and applications that are a joy to use, look no further.</p>
<p>I have been so busy that our <a href="http://www.symbiotica.co.uk">main website</a> still isn&#8217;t ready, but we now have a delicious looking <a href="http://blog.symbiotica.co.uk">blog</a> up and running.</p>
<p><img src='http://www.flipflops.org/wp-content/uploads/2009/09/symblog.jpg' alt='Symbiotica Media Development Ltd - web design &#038; development in Devon' /></p>
<p>If you read flipflops.org regularly, you will rightly guess that we will be working with CakePHP quite a lot, but current projects also make extensive use of <a href="http://www.wordpress.org">WordPress</a> and  <a href="http://tarzan-aws.com">Tarzan AWS</a>. I&#8217;m also built and am using a great a little, lightweight  XML template engine based on the Page Controller pattern, and hopefully more Django soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/09/24/symbiotica-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Win a signed print</title>
		<link>http://www.flipflops.org/2009/08/19/win-a-signed-print/</link>
		<comments>http://www.flipflops.org/2009/08/19/win-a-signed-print/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 22:38:27 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Art]]></category>
		<category><![CDATA[Web Things]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/08/19/win-a-signed-print/</guid>
		<description><![CDATA[To promote my free business listings directory, www.blinks.org.uk I have decided to give away a prize of a signed limited edition print of &#8216;Minibet&#8217; (2005) The 1000th business to register on the site will receive a copy, so register now.]]></description>
			<content:encoded><![CDATA[<p>To promote my <a href="http://www.blinks.org.uk">free business listings directory</a>, <a href="http://www.blinks.org.uk">www.blinks.org.uk</a> I have decided to give away a prize of a signed limited edition print of &#8216;Minibet&#8217; (2005)</p>
<p>The 1000th business to register on the site will receive a copy, so <a href="http://www.blinks.org.uk/users/register">register now</a>.</p>
<p><img src="/blog/uploaded_images/mini_minibet-711521.jpg" width="400" height="281" alt="Register with our free business directory for the chance to win a prize" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/08/19/win-a-signed-print/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Free UK Postcode Geocoding</title>
		<link>http://www.flipflops.org/2009/08/04/free-uk-postcode-geocoding/</link>
		<comments>http://www.flipflops.org/2009/08/04/free-uk-postcode-geocoding/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 14:40:26 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Postcodes]]></category>
		<category><![CDATA[Web Things]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/08/04/free-uk-postcode-geocoding/</guid>
		<description><![CDATA[I&#8217;ve just come across and started using a brilliant new free UK postcode lookup (so far it has provided me with the Latitude &#038; Longitude of every postcode I&#8217;ve thrown at it), it&#8217;s fast, free and easy to use and can return the Latitude &#038; Longitude as either CSV or JSON &#8211; whatever takes your [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just come across and started using a brilliant new free UK postcode lookup (so far it has provided me with the Latitude &#038; Longitude of every postcode I&#8217;ve thrown at it), it&#8217;s fast, free and easy to use and can return the Latitude &#038; Longitude as either CSV or JSON &#8211; whatever takes your fancy. Perhaps best of all, all it requires is the postcode, not other parts of the address like a property name or number.</p>
<p><a href="http://www.ernestmarples.com">http://www.ernestmarples.com</a> (apparently Ernest Marples was the Postmaster general who introduced the postcode to the UK)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/08/04/free-uk-postcode-geocoding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flirting with Django &#8211; part 1</title>
		<link>http://www.flipflops.org/2009/06/29/flirting-with-django-part-1/</link>
		<comments>http://www.flipflops.org/2009/06/29/flirting-with-django-part-1/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 14:10:45 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Web Things]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/06/29/flirting-with-django-part-1/</guid>
		<description><![CDATA[Right now I&#8217;ve got a bit of time on my hands and I am slowly catching up with bits and pieces that I have been meaning to do for years. I have also decided to broaden my horizons and learn some Python and Java. Why Python and Java? Well its simple really; I think Java [...]]]></description>
			<content:encoded><![CDATA[<p>Right now I&#8217;ve got a bit of time on my hands and I am slowly catching up with bits and pieces that I have been meaning to do for years. I have also decided to broaden my horizons and learn some Python and Java.</p>
<p>Why Python and Java? Well its simple really; I think Java would be really useful (in this part of the world), both career wise and in terms of being a better programmer; Python? &#8211; well my best friend raves about it all the time, its a bit different and Django seems so damn sexy (so far I am loving it).</p>
<p>Over the last couple of years I have dabbled with Django, run through the tutorials etc. but never quite had enough time to get to grips with it and Python at the same time. This time I have a specific project in mind and have decided to stick with it until I have something live and kicking on a web server out there in the big wide world.</p>
<p>(Un)fortunately I just blew my book budget on a pair of Java books &#8211; <a href="http://www.amazon.co.uk/gp/product/0672329433?ie=UTF8&#038;tag=flipflopsorg-21&#038;linkCode=as2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=0672329433">Sams Teach Yourself Java 6 in 21 Days</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=flipflopsorg-21&#038;l=as2&#038;o=2&#038;a=0672329433" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> (which is a superb book and I would recommend it to anyone learning Java) and  <a href="http://www.amazon.co.uk/gp/product/1590599047?ie=UTF8&#038;tag=flipflopsorg-21&#038;linkCode=as2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=1590599047">Beginning JSP, JSF &#038; Tomcat Web Development: From Novice to Professional (Beginning from Novice to Professional)</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=flipflopsorg-21&#038;l=as2&#038;o=2&#038;a=1590599047" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> (IMHO a bit mixed some of it is great, but chapters on HTML and Javascript are just filler), so in the absence of paper I have had to resort to the (excellent) online versions <a href="http://www.djangobook.com/">Django Book</a> and <a href="http://diveintopython.org/">Dive into Python</a>. (Personally I&#8217;d take a real book over a screen any day &#8211; you can lie in sunshine in a hammock with your laptop and a beer, but you can&#8217;t see the screen and if you spill the beer it could be an expensive mistake)</p>
<h2>My Setup</h2>
<p>I&#8217;m developing on my laptop which runs Windows XP Professional. I already have an <a href="http://www.apachefriends.org/en/xampp.html">XAMPP webserver</a> running on my laptop. I also have a copy of the <a href="http://www.microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx">Microsoft Power Toy &#8211; Open Command Window here</a>, that lets you open a command prompt in any directory. I&#8217;m using <a href="http://www.netbeans.org/">Netbeans</a> as an IDE, although I did start off with IDLE (the text editor that comes bundled with Python on Windows) but I got driven mad by all the windows.</p>
<p>The Django documentation runs through everything in detail and is a good place to start <a href="http://docs.djangoproject.com/en/dev/intro/install/#intro-install">http://docs.djangoproject.com/en/dev/intro/install/#intro-install</a>. Here is what I did:</p>
<ol>
<li><a href="http://www.python.org/download/">Download  + Install Python</a></li>
<li><a href="http://sourceforge.net/projects/mysql-python">Download + Install MySQL Python</a></li>
<li><a href="http://docs.djangoproject.com/en/dev/topics/install/#installing-official-release">Download + Install Django + Set Paths in your windows environment variables</a></li>
<li><a href="http://www.pythonware.com/products/pil/">Download + Install PIL</a> (Python Imaging Library) so you can work with images</li>
</ol>
<h2>A few thoughts</h2>
<p>Having worked mainly with ASP and PHP, the thing I have found most alien isn&#8217;t anything obvious like syntax differences it is the use of libraries . Of course they exist in PHP &#8211; think about things like PEAR &#8211; but for some reason they are not really a visible part of the language &#8211; PEAR is installed almost ubiquitously and in other cases people seem to just grab a library and dump directly into their application somewhere. Built in libraries (think GD or SPL) are just that built in and people don&#8217;t actually think about them. I think a lot of this is also a reflection of the nature of most PHP hosting which tends to be in cheap (and often shared) hosting environments where it is difficult to (if not impossible) to use non standard libraries, so people stick to the core.</p>
<p>To me therefore,  it feels a little odd to have Django sitting in C:\Python25\Lib\site-packages and my application sitting E:\django\mysite</p>
<h2>Getting started &#8211; create your project</h2>
<p>Go to the directory you want to create your site in and then from the command prompt run:<br />
<code>django-admin.py startproject mysite</code>.<br />
This will create a <em>project</em> called <em>mysite </em>d within your current directory.</p>
<h2>Create you app</h2>
<p>Within a project you can have any number of applications &#8211; I&#8217;ve been thinking of an <em>app</em> as basically a plugin &#8211; a collection of related code. The idea is that you can take a number of <em>apps</em> and put them together inside a project and viola &#8211; a new site. An <em>app</em> might be a products database and shopping cart or it could be a blog or news system. But you can mix them all together and because of the unified Django admin interface they will all fit together perfectly. (<a href="http://docs.djangoproject.com/en/dev/intro/tutorial01/#id3">The Django book explains it pretty clearly</a>)</p>
<blockquote><p>
What&#8217;s the difference between a project and an app? An app is a Web application that does something &#8212; e.g., a weblog system, a database of public records or a simple poll app. A project is a collection of configuration and apps for a particular Web site. A project can contain multiple apps. An app can be in multiple projects.
</p></blockquote>
<p>To create an <em>app</em> Go to the directory you want to create your <em>app</em> in and then from the command prompt run:<br />
<code>django-admin.py startapp shop</code>.<br />
(This would create an <em>app</em> called <em>shop</em> within the <em>mysite</em> <em>project</em>)</p>
<h2>Create your model</h2>
<p>I usually have a pretty accurate database schema down in my notebook before I start any project and although you can import an existing schema and get Django to build the models, the preferred way seems to be to write your models and then get Django to create any necessary database tables based on your models. The latter method is certainly more useful from a learning point of view.</p>
<p>The basic workflow to create your models and synchronise them with the database is very simple indeed:</p>
<ol>
<li>Edit the models.py file within your app</li>
<li>Generate the SQL for your <em>shop app</em> models with:<br />
<code>manage.py sql shop</code>.</li>
<li>Create your database tables with:<br />
<code>manage.py syncdb</code>.</li>
</ol>
<p>How easy is that? </p>
<p><strong>The one thing to watch out for</strong> is that once a table has been created running <em>syncdb</em> will not update the database structure for that table &#8211; you either need to do this manually or use find a schema migration tool to use (something I haven&#8217;t tried yet)</p>
<h2>Templates and Views</h2>
<p>Once you&#8217;ve got a model or two in place, you probably want to do something with it. So you need to write a <em>view</em>. If you are coming from another MVC system, a Django View is basically equivalent to the Controller. I just followed the Django tutorial and played around from there. I didn&#8217;t make any earth shattering discoveries that weren&#8217;t in the book.</p>
<p>Django uses templateing engines to produce its output &#8211; commonly some HTML (but it could be anything, or even empty for AJAX) mixed in with placeholder tags and filters. When you view the page the place holders are replaced with data from the Model by way of the View. The template system seems to be deliberately sparse, but well thought out. If you need more functionality. you cna extend it by defining your own tags and filters or swap in an alternate template system.</p>
<p>You will need to specify the directory that your templates live in settings.py. e.g.<br />
<code><br />
TEMPLATE_DIRS = (<br />
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".<br />
    # Always use forward slashes, even on Windows.<br />
    # Don't forget to use absolute paths, not relative paths.<br />
    'E:/django/mysite/templates'<br />
)</code></p>
<p>If you just want to use <em>Django admin</em> as is you don&#8217;t have to do a thing, but if you want to customise it you can override and of the default <em>admin</em> templates just by creating new ones and placing them in a directory called <em>admin</em> inside your templates directory. Again very straight forward.</p>
<p>The one thing that I got stuck on for a short while is that Django doesn&#8217;t provide any default templates for your the public facing parts of your application. I don&#8217;t think it is that clear on this and I felt a while thinking I was doing something wrong before I realised I actually needed to just make them.</p>
<p>My simple base.html template looks like this:</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
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
&lt;title&gt;{% block title %}{% endblock %}&lt;/title&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;http://static.mysite.com/css/reset.css&quot; type=&quot;text/css&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;http://static.mysite.com/css/base.css&quot; type=&quot;text/css&quot; /&gt;
{% block meta %}{% endblock %}
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;container&quot;&gt;
&nbsp;
	&lt;div id=&quot;header&quot;&gt;
		{% block header %}{% endblock %}
	&lt;/div&gt;
	&lt;div id=&quot;content&quot;&gt;
		{% block content %}{% endblock %}
		&lt;div class=&quot;push&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
	&lt;div id=&quot;footer&quot;&gt;
		{% block footer %}{% endblock %}
	&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>The important thing here is are the placeholder tags e.g. <code>{% block header %}{% endblock %}</code><br />
In this case this is a placeholder for another template fragment called <em>header</em> so you can extend your templates ad infinitum.</p>
<p>Which brings me on to the only part of my Django experience so far that wasn&#8217;t great, it was the hair-pullingly frustrating experience of setting up to serve static files&#8230;</p>
<h2>Serving Static Files</h2>
<p>Django doesn&#8217;t like to serve static files (think css, js etc.). Even though I&#8217;m just developing on my laptop at the moment, I thought that it would be a good idea to try and mimic a production setup as closely as possible, and reading around the sensible thing to do was just serve all my static files from a sub domain. I&#8217;ve also got a copy of XAMPP running on my machine so I set up a subdomain in that to serve static files and experienced a total nightmare. I&#8217;m not quite sure why I had so much trouble, but I did, and I would imagine that this is the step where a lot of other people give up. Of course I got it working in the end (or else I probably wouldn&#8217;t be writing this, or at least not in a wow Django is so so cool kind of way&#8230;)</p>
<p><strike>In the end I did get it working and it is possible that it is slightly weird. My actual Django project directory is within my XAMPP directory structure (because this is where I store all my code), but it is not served by the XAMPP Apache server (yet) &#8211; instead it is served using the python server: <em>python manage.py runserver</em> on <em>http://127.0.0.1:8000/ </em></strike></p>
<p><strike>So for the moment my static files are within the Django project (in the static directory) and can be accessed at: http://static.simbiotica.co.uk &#8211; in my settings.py has the following settings:</p>
<p></strike></p>
<p><code><strike><br />
# Absolute path to the directory that holds media.<br />
# Example: "/home/media/media.lawrence.com/"<br />
MEDIA_ROOT = './static/'</p>
<p># URL that handles the media served from MEDIA_ROOT. Make sure to use a<br />
# trailing slash if there is a path component (optional in other cases).<br />
# Examples: "http://media.lawrence.com", "http://example.com/media/"<br />
#MEDIA_URL = 'http://static.simbiotica.co.uk'<br />
MEDIA_URL = '/static/'</strike></code></p>
<p><strong>Update 19th July 2009</strong></p>
<p>It turns out I was wrong! Thought it was all working, but when I started to dig deeper it wasn&#8217;t. Close though I think. For development have gone back to a more conventional setup in my <a href="http://www.flipflops.org/2009/07/19/flirting-with-django-part-2/">latest post</a>.</p>
<p><img src='http://www.flipflops.org/wp-content/uploads/2009/06/python.gif' alt='Django Files' /></p>
<h2>The story so far&#8230;</h2>
<p>So far my Django experience has been very positive and I can&#8217;t wait to get my first site done. I&#8217;ve successfully plugged in the <a href="http://code.google.com/p/django-filebrowser/">Django Filebrowser</a> into my admin system too. I think the thing I like most is wonderful terseness &#8211; you can achive so much writing so little, and from my currently extremely limited Python experience I&#8217;m really enjoying the language too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/06/29/flirting-with-django-part-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>New business directory seeks businesses</title>
		<link>http://www.flipflops.org/2009/06/17/new-business-directory-seeks-businesses/</link>
		<comments>http://www.flipflops.org/2009/06/17/new-business-directory-seeks-businesses/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 11:41:41 +0000</pubDate>
		<dc:creator>Flipflops</dc:creator>
				<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Web Things]]></category>

		<guid isPermaLink="false">http://www.flipflops.org/2009/06/17/new-business-directory-seeks-businesses/</guid>
		<description><![CDATA[I&#8217;ve been working on a business directory website in my spare time for a while and it is now live. The directory is www.blinks.org.uk and is for for companies / organisations / individuals based in the UK who want to promote their businesses. It is totally free to register and you won&#8217;t find any registration [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a business directory website in my spare time for a while and it is now live. The directory is <a href="http://www.blinks.org.uk"><strong>www.blinks.org.uk</strong></a> and is for for companies / organisations / individuals based in the UK who want to promote their businesses. It is totally free to register and you won&#8217;t find any registration details sold or passed on to anybody!</p>
<p>At the moment it is still very much in a testing stage and I&#8217;m after feedback. Comments suggestions etc. would be greatly appreciated.</p>
<p>The site is written with the wonderful CakePHP framework (and god bless view caching)</p>
<p><a href="http://www.blinks.org.uk"><img src='http://www.flipflops.org/wp-content/uploads/2009/06/blinks4.gif' alt='blinks.org.uk - Free UK business directory' /></a></p>
<p><strong>Tell me more&#8230;</strong></p>
<p>The sign up process is quick and easy and only requires that you confirm the email address you register with (this email remains private and is not displayed on the site). </p>
<p>When you have registered you can add as many businesses as you want. You can add the following information for each business you add:</p>
<ul>
<li>Company name</li>
<li>Website Address</li>
<li>Contact Details<br /><small>These are mandatory, although you can elect not to show them on the website</small></li>
<li>Summary</li>
<li>Long Description</li>
<li>Image or Logo</li>
<li>List your business in up to 5 Categories</li>
</ul>
<p><a href="http://www.blinks.org.uk/users/register">Click here to register today!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.flipflops.org/2009/06/17/new-business-directory-seeks-businesses/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

