<?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>Koodoz Design &#187; Development</title>
	<atom:link href="http://www.koodoz.com.au/tag/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.koodoz.com.au</link>
	<description>Koodoz Design is a creative design studio based in Richmond, Melbourne. We help businesses unleash their full potential through visual communication and clever design.</description>
	<lastBuildDate>Mon, 23 Jan 2012 03:40:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Newspaper Style Columns With (and Without) CSS3</title>
		<link>http://www.koodoz.com.au/klog/web-design-html-xhtml-css-cascading-style-sheets-hyper-text-markup-language-javascript-flash-php/newspaper-style-columns-with-and-without-css3/</link>
		<comments>http://www.koodoz.com.au/klog/web-design-html-xhtml-css-cascading-style-sheets-hyper-text-markup-language-javascript-flash-php/newspaper-style-columns-with-and-without-css3/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 03:34:04 +0000</pubDate>
		<dc:creator>Daniel Angel</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[columns]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[newspaper]]></category>

		<guid isPermaLink="false">http://www.koodoz.com.au/?p=1346</guid>
		<description><![CDATA[

One of the coolest features of CSS3 is the ability &#8230;]]></description>
			<content:encoded><![CDATA[<img src="http://www.koodoz.com.au/wp-content/uploads/2009/08/columns.jpg" alt="Newspaper" title="columns" width="300" height="293" class="size-full wp-image-1416" style="margin-bottom: 40px;" />

<p>One of the coolest features of CSS3 is the ability to create newspaper-like columns on your layouts without any extra markup. We always find ourselves &#8220;cheating&#8221;, using things like <code>&lt;div id=&quot;column-one&quot;&gt;</code> which is not very good, so this property would save us a lot of time and unnecessary code.</p>

<p>CSS3 solves all this with the use of some really cool properties: <code>column-width</code>, <code>column-gap</code> and <code>column-rule</code>. I guess they&#8217;re pretty self explanatory, except for <code>column-rule</code> which basically behaves like a border in between columns, so it can be treated like one, using width, style, etc. If you need more details, you can <a href="http://www.w3.org/TR/css3-multicol/" rel="external">go to the source</a>.<span id="more-1346"></span><p>

<p>The problem? you guessed it! It&#8217;s still not supported by some browsers, namely IE and Opera (need to check IE8 and Chrome, though). Anyway, for this blog post I decided to start testing cross-browser solutions for the problem and this is what I&#8217;ve come up with so far.</p>

<p>First, we use the property for the browsers that support it, so if we have something like:</p>

<p>
<pre>
&lt;div id=&quot;content&quot;&gt;
&lt;p&gt;The quick brown fox jumped over the lazy dog&lt;/p&gt;
&hellip;
&lt;p&gt;And they lived happily everafter&lt;/p&gt;
&lt;/div&gt;
</pre>
</p>

<p>we then style it like this:</p>

<p>
<pre>
div#content {
	-moz-column-count: 4;
	-webkit-column-count: 4;
}
</pre>
</p>

<p>Notice the prefixes <code>-moz</code> and <code>-webkit</code>. The reason for their presence lies in the fact that amazingly enough, the specification is still a draft (it was originally suggested in 2004!), so we need those. They&#8217;re obviously not 100% standard but in this case I would favour common sense as opposed to standards compliance. The styles themselves can get immensely fancier, using the <code>column-gap</code> and <code>column-rule</code> properties, but let&#8217;s keep it simple for the purposes of this post.</p>

<p>If you use a decent browser and look at that code, you should see something like this:</p>

<img src="http://www.koodoz.com.au/wp-content/uploads/2009/08/columns-01.jpg" alt="Demonstration of CSS columns on decent browsers" title="columns-01" width="540" height="239" class="size-full wp-image-1405 center" />

<p>Everyone else should see the style-less rendering:</p>

<img src="http://www.koodoz.com.au/wp-content/uploads/2009/08/columns-02.jpg" alt="Document without columns styling" title="columns-02" width="540" height="176" class="size-full wp-image-1407 center" />

<h3>Taking care of all other browsers</h3>

<p>So, to make sure no one else misses out on the fun, we can use a little jQuery. There are many jQuery plugins to deal with multi-columns, but <a href="http://www.systemantics.net/en/columnize" rel="external">Systemantics&#8217; columnize</a> plugin was the best-suited one I could find, so cheers to them!</p>

<p>We don&#8217;t want to apply the columnize styles to the browsers that support <code>column-width</code>, so we need to serve the javascript only to those that absolutely need it. You can do so by using jQuery&#8217;s browser detection, but I would suggest using <code><a href="/klog/development/getting-phps-get_browser-function-to-work-on-your-site/">get_browser()</a></code> instead. It gives you much more control:</p>

<p>
<pre>
&lt;?php if ( ($browser != &#039;Firefox&#039;) &amp;&amp; ($browser != &#039;Safari&#039;) ) { ?&gt;	
	// enter columnize code here
&lt;?php } ?&gt;
</pre>
</p>

<p>Using columnize is pretty straightforward. You invoke jquery and the plugin, and then simply do something like:</p>

<p>
<pre>
$(&quot;#content&quot;).columnize({columns: 4});
</pre>
</p>

<p>By default, columnize adds the class <code>.column</code> to each of the generated columns, so be sure to style it properly. The overall width of each element should be equal to the width of the parent element, divided by the number of columns, so for instance, if your parent element is 1200px wide and you have four columns, the overall width of each <code>.column</code> element should be 300px. Columnize has tons of other options as well, so be sure to check them out.<p>

<p>You can <a href="/demos/css-columns/">look at the demonstration here</a>. As usual, comments and questions are always welcome. Thanks for reading!</p>]]></content:encoded>
			<wfw:commentRss>http://www.koodoz.com.au/klog/web-design-html-xhtml-css-cascading-style-sheets-hyper-text-markup-language-javascript-flash-php/newspaper-style-columns-with-and-without-css3/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Getting PHP&#8217;s get_browser() function to work on your site</title>
		<link>http://www.koodoz.com.au/klog/development/getting-phps-get_browser-function-to-work-on-your-site/</link>
		<comments>http://www.koodoz.com.au/klog/development/getting-phps-get_browser-function-to-work-on-your-site/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 00:01:05 +0000</pubDate>
		<dc:creator>Daniel Angel</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[get_browser]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://www.koodoz.com.au/?p=1084</guid>
		<description><![CDATA[

OK, this one&#8217;s a bit more technical than usual!

On a &#8230;]]></description>
			<content:encoded><![CDATA[<img src="http://www.koodoz.com.au/wp-content/uploads/2009/07/get_browser.png" alt="get_browser(): learning to use PHP&#039;s browser identifying function" title="get_browser" width="300" height="241" class="size-full wp-image-1097" />

<p>OK, this one&#8217;s a bit more technical than usual!</p>

<p>On <a href="http://www.koodoz.com.au/klog/development/youtube-is-dropping-ie6-support-should-you/">a previous post</a>, I discussed how you could use PHP&#8217;s <code>get_browser()</code> function to detect your users&#8217; browser information. You may need to do this for a number of reasons: fixing small CSS details (for instance, positioning <code>&lt;button&gt;</code> elements next to input fields and getting them to display correctly) and preventing your users from seeing stuff reserved for the googlebot<sup>&#8224;</sup> are some examples that come to mind.<span id="more-1084"></span></p>

<p>If all you want is to load an extra style sheet for Internet Explorer, you can do so with conditional comments, but what about if you want to fix an Opera or Safari issue? What if you want to be nice to <a href="http://www.konqueror.org/" rel="external">Konqueror</a> users and fix that small detail that prevents your site from displaying <em>exactly</em> as you want it to? Enter PHP and its <code>get_browser()</code> function. According to <a href="http://au2.php.net/manual/en/function.get-browser.php" rel="external">the manual</a>, the function will return an array or an object filled with information about the user&#8217;s browser.</p>

<p>However, I&#8217;ve heard many people complain about how the function just doesn&#8217;t work on their site. If you take a careful look at the manual, you&#8217;ll notice the following notice further down:</p>

<blockquote>
<p>In order for this to work, your browscap configuration setting in php.ini must point to the correct location of the browscap.ini file on your system.</p>
</blockquote>

<p>As it turns out, you need a file called browscap.ini (or php_browscap.ini) which <em>doesn&#8217;t come bundled with PHP</em> so chances are that your web host doesn&#8217;t have it installed by default.</p>

<p><small>&#8224; Careful with this one. You need very good reasons to serve the googlebot different content. Exercise common sense.</small></p>

<h3>Checking for (and installing) browscap.ini</h3>

<p>The first thing you need to do is to check if your system has browscap.ini installed and if not, can you do so by yourself. Open your favourite text editor and invoke the <code>phpinfo()</code> function. This will help you gather some information about your system:</p>

<p>
<pre>
&lt;?php phpinfo(); ?&gt;
</pre>
</p>

<p>Save the file. You can name it <em>info.php</em> and upload it to your server&#8217;s root directory. Now, browse to said page and use the <em>find</em> tool on your browser and look for the word &ldquo;<em>browscap</em>&rdquo;. You should come across a table with three columns. Look at what the values are next to the word <em>browscap</em>. If there&#8217;s a path to a file, you&#8217;re set! Skip to the next section of this post. However, if you see <em>no value</em>, you need to do a little bit more work, so keep reading.</p>

<img src="http://www.koodoz.com.au/wp-content/uploads/2009/07/php-ini.png" alt="Screenshot of phpinfo()" title="php-ini" width="540" height="136" class="size-full wp-image-1098 center" />

<p>The PHP manual points users to <a href="http://browsers.garykeith.com/stream.asp?PHP_BrowsCapINI">this file</a>, which is kindly maintained by <a href="http://browsers.garykeith.com/index.asp">Gary Keith</a>, so <em>koodoz</em> to him. Download it and upload it to your server, preferably outside the root www folder. Keep in mind the file&#8217;s absolute path on your server.</p>

<p>Now go back to that info.php page and look for <strong>Configuration File (php.ini) Path</strong>. This is where your PHP configuration file is located. Download the php.ini file and open it with your text editor.</p>

<p><strong>N.B: If your host doesn&#8217;t give you access to this folder, they need to do all the work. Get in touch with them and ask them to install browscap.ini.</strong></p>

<p>Again, look for the word <em>browscap</em> and enter the absolute path to your newly-uploaded browscap file. After you&#8217;re done, it should look something like this:</p>

<p>
<pre>
[browscap]
browscap = /path/to/your/php_browscap.ini
</pre>
</p>

<p>Save and re-upload the file. Depending on your host, they might need to restart the http server, but if you have access to the php.ini file, chances are you don&#8217;t, so that&#8217;s it. If everything&#8217;s been done correctly, you can now use <code>get_browser()</code>.</p>

<h3>Using the <code>get_browser()</code> function</h3>

<p>There are millions of ways in which you can use the power of this function. To start, open your text editor and create the following file:</p>

<p>
<pre>
&lt;?php
$browser = get_browser(null, true);
?&gt;

&lt;pre&gt;
&lt;?php print_r($browser); ?&gt;
&lt;/pre&gt;
</pre>
</p>

<p>Take a look at the results, they&#8217;re pretty detailed! <code>$browser['platform']</code>, <code>$browser['browser']</code> and <code>$browser['majorver']</code> show you the operating system, browser and version respectively (bo-ring!), but then you have stuff like <code>$browser['cssversion']</code>, <code>$browser['issyndicationreader']</code> and <code>$browser['ismobiledevice']</code> which can be used to do all sorts of things! Endless potential, I say.</p>

<p>Anyway, hope this was useful and feel free to comment to discuss or get some extra help :)</p>]]></content:encoded>
			<wfw:commentRss>http://www.koodoz.com.au/klog/development/getting-phps-get_browser-function-to-work-on-your-site/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

