<?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>signalkraft</title>
	<atom:link href="http://signalkraft.com/feed" rel="self" type="application/rss+xml" />
	<link>http://signalkraft.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 18 Oct 2010 20:49:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Real-World Examples of PHP5.3</title>
		<link>http://signalkraft.com/real-world-examples-of-php5-3</link>
		<comments>http://signalkraft.com/real-world-examples-of-php5-3#comments</comments>
		<pubDate>Mon, 18 Oct 2010 20:34:08 +0000</pubDate>
		<dc:creator>Philipp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://signalkraft.com/?p=306</guid>
		<description><![CDATA[Some snippets of code explaining why PHP 5.3 matters in every-day use.]]></description>
			<content:encoded><![CDATA[<p>Without further ado, here’s some cool stuff that only works in the latest big release of PHP:</p>
<div class="codeCaption">Adding Data to an Array</div>
<pre><code>&lt;?php
	
	$blogPosts = getBlogPosts();
	$postsWithPictures = array();
	
	// The old way...
	foreach($blogPosts AS $key =&gt; $post)
	{
		$postsWithPictures[$key] = $post;
		$postsWithPictures[$key]['pictures'] = getPostPictures($post['id']);
	}
	
	// ...the anonymous function...
	$postsWithPictures = array_map(
		function($post) {
			$post['pictures'] = getPostPictures($post['id']);
			return $post;
		},
		$blogPosts
	);
	
	// ...and the lambda:
	
	$addPictures = function($post) { 
		$post['pictures'] = getPostPictures($post['id']); return $post; 
	};
	
	$postsWithPictures = array_map($addPictures, $blogPosts);</code></pre>
<p>The final verdict on performance is still out — in theory the procedural style of <code>foreach</code> loops is <em>slightly</em> quicker than <code>array_map</code>, as the latter adds a function call to every iteration. We’re talking milliseconds here, and in this example <code>getPostPictures()</code> would probably slow down all three examples to an equally slow pace.</p>
<h3>Closures as Function Arguments</h3>
<p>Imagine you have a HTML helper function that generates anchors from a route…</p>
<pre><code>&lt;?php echo anchor('Blog/archive', 'Archive'); ?&gt;</code></pre>
<p>…using your framework’s Router library the result might look like this:</p>
<pre><code>&lt;a href="http://blog.com/myblog/archive.html"&gt;Archive&lt;/a&gt;</code></pre>
<p>In one particular case you need to alter the generated link slightly. You could hardcode that specific case into the function itself and add another parameter, or you could add a much more future-proof method of changing the HTML layout with a third, optional Closure argument:</p>
<pre><code>&lt;?php
	$wrapper = function($route, $name) {
		return "&lt;span target=\"$route\"&gt;$name&lt;/span&gt;";
	}
	echo anchor('blog/archive', 'Archive', $wrapper);
?&gt;</code></pre>
<p>The <code>anchor</code> function definition could look like this:</p>
<pre><code>&lt;?php
function anchor($route, $name, \Closure $wrapper = null) {
	if (is_null($wrapper)) {
		$wrapper = function($route, $name) {
			$href = MyFramework::getRouter()->resolve($route);
			return "&lt;a href=\"\"&gt;$name&lt;/span&gt;";
		}
	}
	return $wrapper($route, $name);
}
?&gt;</code></pre>

<p>This means you now covered all possible usage scenarios involving the layout of the generated HTML.</p>
<p>The <a href="http://php.net/manual/de/language.oop5.typehinting.php">typehint</a> in the 2nd line (<code>\Closure</code>) “hints” at another fantastic new feature in PHP 5.3 — namespaces.</p>
<p>You should check out the latest development in <a href="http://www.doctrine-project.org/blog/php-5-3-and-doctrine-2-0-teaser">Doctrine 2.0</a> for some real-world usage of namespaces.</p>]]></content:encoded>
			<wfw:commentRss>http://signalkraft.com/real-world-examples-of-php5-3/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hochfügen Promo Clip</title>
		<link>http://signalkraft.com/hochfugen-promo-clip</link>
		<comments>http://signalkraft.com/hochfugen-promo-clip#comments</comments>
		<pubDate>Wed, 13 Oct 2010 14:38:16 +0000</pubDate>
		<dc:creator>Philipp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://signalkraft.com/?p=315</guid>
		<description><![CDATA[Promo trailer for Hochfügen &#038; Kneissl.]]></description>
			<content:encoded><![CDATA[<p>The friendly bunch at <a href="http://mischfabrik.com/">Mischfabrik.com</a> finished last season’s big project for <a href="http://hochfuegenski.com/content/">Hochfügen</a> ski resort, after a long summer of editing &amp; cutting hours of raw material.</p>

<p>All of it was shot with GoPro helmet cams and one “proper” HD cam. Best served cold, in 1080p and on a big screen:</p>

<object width="700" height="420"><param name="movie" value="http://www.youtube.com/v/9lksHSsVNHQ?fs=1&amp;hl=de_DE"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/9lksHSsVNHQ?fs=1&amp;hl=de_DE" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="700" height="420"></embed></object>

<p>Time well spent.</p>]]></content:encoded>
			<wfw:commentRss>http://signalkraft.com/hochfugen-promo-clip/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Toycamera AnalogColor</title>
		<link>http://signalkraft.com/toycamera-analogcolor</link>
		<comments>http://signalkraft.com/toycamera-analogcolor#comments</comments>
		<pubDate>Mon, 31 May 2010 09:38:24 +0000</pubDate>
		<dc:creator>Philipp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://signalkraft.com/?p=299</guid>
		<description><![CDATA[Cross-Process digital photos.]]></description>
			<content:encoded><![CDATA[<a href="http://www.flickr.com/photos/signalkraft/4655775208/"><img src="http://farm5.static.flickr.com/4025/4655775208_703f436622_b.jpg" alt="" /></a>
<p><a href="http://www.pentacom.jp/pentacom/toycamera_analogcolor/">Toycamera AnalogColor</a> does cross-processing per drag &amp; drop. Download on the lower left of the website.</p>]]></content:encoded>
			<wfw:commentRss>http://signalkraft.com/toycamera-analogcolor/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inherit Template Parser</title>
		<link>http://signalkraft.com/inherit-template-parser-codeigniter</link>
		<comments>http://signalkraft.com/inherit-template-parser-codeigniter#comments</comments>
		<pubDate>Wed, 19 May 2010 19:16:57 +0000</pubDate>
		<dc:creator>Philipp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://signalkraft.com/?p=270</guid>
		<description><![CDATA[Django-like template inheritance in Codeignigter.]]></description>
			<content:encoded><![CDATA[<h2 id="or">…for the Codeigniter PHP Framework</h2>

<div id="download" onclick="window.location.href = 'http://signalkraft.com/media/inherit_template_0.1.zip'">
	<h3><a id="download_link" href="http://signalkraft.com/media/inherit_template_0.1.zip">Download <strong>Inherit Template Parser for Codeigniter</strong></a></h3>
	<p class="version">Version 0.1</p>
	<p class="license">Licensed under <a href="http://www.gnu.org/licenses/gpl-2.0.txt">GNU GPL v2</a>
</div>

<p>This template parser extends the existing <a href="http://codeigniter.com/user_guide/libraries/parser.html">Codeigniter Parser</a> with inheritance and blocks, inspired by the excellent <a href="http://www.djangoproject.com/">Django Python Framework</a>.<p>

<h2>Important Features</h2>
<ul class="check">
	<li><strong>Easy to use:</strong> <a href="#example">See the example</a> to get started,</li>
	<li><strong>DRY:</strong> <a href="#dry">Never, ever repeat yourself in your templates again</a>,</li>
	<li><strong>Tiny footprint:</strong> Only one file necessary, drops right in if you were using the CI Parser before,</li>
	<li><strong>Themes &amp; Language:</strong> This class does <a href="#themes_language">simple theming and language variables</a>.</li>
</ul>

<a name="dry"></a>
<h2>DRY — Don’t repeat yourself</h2>
<p>This simple parser aims to remove 99% of all code redundancy in your Codeigniter templates, without the complications of a much larger templating engine like Smarty. <em>Inherit</em> extends the Codeigniter Parser, is designer-friendly and relies entirely on a proven concept.</p>
<p>Repeating yourself is bad, even and especially in your templates. In PHP we are used to inheriting Classes to replicate certain functionality and have consistent functions and variables we can fall back on — it’s what makes Codeigniter so great. But the same should be true for your templates, shouldn’t it? Instead you write a lot of <code>include("this")</code> and <code>include("that")</code>.</p>
<p>Maybe slightly worse, you might load header and footer in your controller and put them in variables for the view to use — making it difficult for the designer to trace back where that header content is coming from and how he can change it. Stick around and read the <a href="#example">example</a> to find out about a better solution.</p>

<h2>Installation</h2>
<p>Download the library, extract the contents to your <code>system</code> folder. Put it in your autoload config or load it in your controller. <a href="#example">See the example below for a quick howto</a>.

<a name="example"></a>
<h2>Example</h2>
<p>Instead of needlessly splitting your website into a header, a footer, and everything in between we will now create a base template:</p>
<div class="codeCaption">application/views/base.php</div>
<pre><code>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
	&lt;title&gt;{block=&quot;title&quot;}My Website!{/block}&lt;/title&gt;

	&lt;link rel=&quot;stylesheet&quot; href=&quot;css/style.css&quot; type=&quot;text/css&quot; /&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;h1&gt;Header!&lt;/h1&gt;
&lt;div id=&quot;content&quot;&gt;
{block=&quot;content&quot;}Default content, nobody probably reads this.{/block}
&lt;/div&gt;
&lt;p&gt;{block=&quot;footer&quot;}Footer, copyright me 2010.{/block}&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>This is our base, all the different controllers simply extend it:</p>
<div class="codeCaption">application/views/welcome.php</div>
<pre><code>{extends="base"}

{block_prepend="title"}Home - {/title}
{block="content"}Hello World, this is my welcome page.{/content}</code></pre>
<p>Now you simply call <code>$this->parser->parse("welcome");</code> and the output looks like this:</p>
<pre><code>&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
	&lt;title&gt;Home - My Website!&lt;/title&gt;

	&lt;link rel=&quot;stylesheet&quot; href=&quot;css/style.css&quot; type=&quot;text/css&quot; /&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;h1&gt;Header!&lt;/h1&gt;
&lt;div id=&quot;content&quot;&gt;
Hello World, this is my welcome page.
&lt;/div&gt;
&lt;p&gt;Footer, copyright me 2010.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>Notice how it prepended the HTML title, left the footer alone and completely overwrote the content? It’s all thanks to inheritance, and it works just like it does in PHP5.</p>
<p>For a more “real-world” example, you could extend <code>base.php</code> with templates called <code>one_column</code> and <code>two_column</code>, then extend those with your pages. Now, if you ever wanted to add a second column to your welcome screen, just point the <code>{extends}</code> block to two_column, instead of one_column. It couldn’t be easier, and there is zero code overhead.</p>
<h2>Performance Caveat</h2>
<p>This is the first public release of <em>Inherit</em>. There’s gonna be bugs and there definitely are huge performance improvements waiting to happen. Neither stopped me from successfully using this library on several production websites. If you’re experiencing a high volume of visitors, wait until I put in Caching in the next major release. For your personal blog or portfolio it will probably hold up, performance-wise.</p>

<a name="themes_language"></a>
<h2>More Functions</h2>
<p><em>Inherit</em> includes a language file simply called “views”. In it you will find a multi-dimensional array of this format:</p>

<div class="codeCaption">application/language/english/views_lang.php</div>
<pre><code>&lt;?php

    $lang['welcome'] = array(
		'title' => 'My welcome title'
	);
	
	$lang['blog/index'] = array(
		'title' => 'My blog title',
		'archive' => 'View the blog archives'
	);

?&gt;</code></pre>
<p>The array associated with each view URI is available within that view as <code>$lang</code>. In this example, calling <code>$lang['title']</code> on your welcome page will return a different value than calling it on your blog index.</p>

<h3>Themes</h3>
<p>Basically, calling <code>$this->parser->theme('blue'); $this->parser->parse('welcome');</code> will attempt to parse the file <code>views/blue/welcome.php</code>. If it doesn’t exist, the default view is used instead (<code>views/welcome.php</code>). So even your themes inherit a parent, if you want them to.</p> 
<p>Similarly, if <code>views/blue/welcome.php</code> extends a template, it will first look for that parent in <code>views/blue/</code>, then in the default theme folder (usually <code>views/</code>).</p>
<p>You can tell <em>Inherit</em> to look for the default views somewhere else, if you set the appropriate variable in <code>MY_Parser.php</code>. Watch this section for more comprehensive documentation in the future.</p>]]></content:encoded>
			<wfw:commentRss>http://signalkraft.com/inherit-template-parser-codeigniter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>White Powder is my Drug of Choice</title>
		<link>http://signalkraft.com/white-powder</link>
		<comments>http://signalkraft.com/white-powder#comments</comments>
		<pubDate>Thu, 08 Apr 2010 08:48:18 +0000</pubDate>
		<dc:creator>Philipp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://signalkraft.com/?p=220</guid>
		<description><![CDATA[Freeriding photos taken in Hochfügen.]]></description>
			<content:encoded><![CDATA[<p>These were taken in March of 2010 in the excellent freeriding resort Hochfügen, Austria. Thanks to Mischfabrik &amp; Kneissl for their brilliant riding, and thanks to Hochfügen for all those tickets.</p>
<div class="gallery">
<img src="http://farm5.static.flickr.com/4009/4434395177_9f2e5822e0_b.jpg" alt="" />
<img src="http://farm5.static.flickr.com/4007/4434396653_e3ee5e5c4b_b.jpg" alt="" />
<img src="http://farm3.static.flickr.com/2734/4434394323_d9983dc791_b.jpg" alt="" />
<img src="http://farm3.static.flickr.com/2734/4481614077_33106cc1e7_o.jpg" alt="" />
<img src="http://farm5.static.flickr.com/4057/4481662295_6f93a5e896_o.jpg" alt="" />
<img src="http://farm5.static.flickr.com/4066/4481613773_29cc7172e2_o.jpg" alt="" />
</div>
<p>On the technical side of things, these were taken with a Nikon F4S and a Nikkor f5.6 50-300m zoom lens. Largely unaltered, the colors came out of the camera like that. Gotta ♥ analog.</p>]]></content:encoded>
			<wfw:commentRss>http://signalkraft.com/white-powder/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sticky Footer in 960 Grid System</title>
		<link>http://signalkraft.com/sticky-footer-in-960-grid-system</link>
		<comments>http://signalkraft.com/sticky-footer-in-960-grid-system#comments</comments>
		<pubDate>Wed, 31 Mar 2010 13:21:46 +0000</pubDate>
		<dc:creator>Philipp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wp.signalkraft.com/?p=203</guid>
		<description><![CDATA[Make your footer stick to the bottom of each page.]]></description>
			<content:encoded><![CDATA[<h2 id="or">…and other CSS Frameworks</h2>
<p>“Sticky Footers” are containers that stick to the bottom of every page, no matter how much whitespace is between the footer and the preceding content. A <a href="http://www.cssstickyfooter.com/">popular method</a> involves fixed height, negative margins &amp; paddings as well as a number of hacks to ensure cross-browser compatibility.</p>
<p>Here’s how you adapt CSS Sticky Footer to the 960.gs Grid CSS Framework:</p>
<h2>Quick Steps</h2>
<ol>
	<li><a href="#footer_css">Add the footer CSS</a> to your 960.css</li>
	<li>Search &amp; Replace <code>150px</code> in the CSS with the real height of your footer</li>
	<li>You need the elements <code>#wrapper</code> and <code>#content</code> in your HTML above the footer (<a href="#html_after">see example</a>)</li>
</ol>
<h3>Before</h3>
<p>This might be how part of your website looks now:</p>
<div class="codeCaption">HTML (before)</div>
<pre><code>&lt;body&gt;
	&lt;div id=&quot;content&quot; class=&quot;container_16&quot;&gt;
		&lt;!-- Content --&gt;
	&lt;/div&gt;
	&lt;div id=&quot;footer&quot;&gt;
		&lt;!-- Footer --&gt;
	&lt;/div&gt;
&lt;/body&gt;</code></pre>

<a name="html_after"></a>
<h3>After</h3>
<p>This sticky footer needs two surrounding wrappers above it, so go ahead and add another around <code>#content</code>. I’ve called it <code>#wrapper</code> in this example:</p>
<div class="codeCaption">HTML (after)</div>
<pre><code>&lt;body&gt;
	&lt;div id=&quot;wrapper&quot;&gt;
		&lt;div id=&quot;content&quot; class=&quot;container_16&quot;&gt;
			&lt;!-- Content --&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;div id=&quot;footer&quot;&gt;
		&lt;!-- Footer --&gt;
	&lt;/div&gt;
&lt;/body&gt;</code></pre>

<a name="footer_css"></a>
<p>Here’s how the CSS should look, this example assumes your footer is <code>150px</code> high.</p>
<div class="codeCaption">CSS</div>
<pre><code>/*  
Sticky Footer Solution
by Steve Hatcher
http://stever.ca http://www.cssstickyfooter.com
*/

html, body, #wrapper {height: 100%;}

body &gt; #wrapper { height: auto; min-height: 100%; }

/* must be same height as the footer */
#content { overflow: auto; padding-bottom: 150px; } 

#footer {
	position: relative;
	margin-top: -150px; /* negative value of footer height */
	height: 150px;
	clear: both;
} 

/*Opera Fix*/
body:before { /* thanks to Maleika (Kohoutec)*/
	content: &quot;&quot;;
	height:100%;
	float: left;
	width: 0;
	margin-top: -32767px; /* thank you Erik J */
}</code></pre>]]></content:encoded>
			<wfw:commentRss>http://signalkraft.com/sticky-footer-in-960-grid-system/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NLT Mixtape Three</title>
		<link>http://signalkraft.com/nlt-mixtape-three</link>
		<comments>http://signalkraft.com/nlt-mixtape-three#comments</comments>
		<pubDate>Tue, 08 Dec 2009 13:12:15 +0000</pubDate>
		<dc:creator>Philipp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wp.signalkraft.com/?p=142</guid>
		<description><![CDATA[The 3rd nothinglikethis mixtape has arrived.]]></description>
			<content:encoded><![CDATA[<a href="http://nothinglikethis.de/archives/71"><img alt="" src="/media/audio/nltmixtapethree/nltmixtapethree.jpg" title="nltmixtapethree" width="500" /></a>
<br /><br />
]]></content:encoded>
			<wfw:commentRss>http://signalkraft.com/nlt-mixtape-three/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Netbeans and PHP Frameworks</title>
		<link>http://signalkraft.com/netbeans-and-codeigniter</link>
		<comments>http://signalkraft.com/netbeans-and-codeigniter#comments</comments>
		<pubDate>Wed, 04 Nov 2009 13:04:54 +0000</pubDate>
		<dc:creator>Philipp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wp.signalkraft.com/?p=112</guid>
		<description><![CDATA[A word about code completion.]]></description>
			<content:encoded><![CDATA[<h2 id="or">Codeigniter, CakePHP &amp; Other MVC Frameworks</h2>

<p>Netbeans’ end-all feature and subject of this write-up is code completion. It truely shines when you hit <code>Ctrl + Space</code>. It neatly marks up, indents and auto-completes any combination of PHP, HTML, CSS &amp; JS you throw at it — even if they’re all in the same PHP file.</p>
<p><img src="/media/netbeans_completion.jpg" alt="" /></p>
<p>There’s just one issue I’ve run into: Completion doesn’t work for built-in functions of most MVC Frameworks, for instance CakePHP &amp; Codeigniter, and between any models and controllers you created. The connection of all these classes within the instance of the framework just isn’t apparent to the editor.</p>

<h3>Auto-Completion in MVC Frameworks</h3>
<p>The remedy here is to add <code>@property</code> PHPDoc meta data for all functions. Normally, this would mean changing all core Classes as well as your own. Fortunately <a href="http://rhasan.com/blog/2009/09/codeigniter-auto-complete-with-netbeans/">Rakibul Hasan</a> has shown us the light: By adding a prototype of your <code>Model()</code> and <code>Controller()</code> functions in the <code>nbproject</code> folder you can give Netbeans the additional meta data without touching your existing application.</p>

<p>Although it’s advertised for Codeigniter, it works just as well for other frameworks where all your code sits in classes extending a controller or a model parent — such as CakePHP.</p>]]></content:encoded>
			<wfw:commentRss>http://signalkraft.com/netbeans-and-codeigniter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sitemaps for CodeIgniter</title>
		<link>http://signalkraft.com/sitemaps-for-codeigniter</link>
		<comments>http://signalkraft.com/sitemaps-for-codeigniter#comments</comments>
		<pubDate>Thu, 29 Oct 2009 12:02:54 +0000</pubDate>
		<dc:creator>Philipp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wp.signalkraft.com/?p=159</guid>
		<description><![CDATA[Generate sitemaps for Google and others.]]></description>
			<content:encoded><![CDATA[<h2 id="or">Google, Yahoo, Bing &amp; Others</h2>

<div id="download" onclick="window.location.href = 'http://signalkraft.com/media/sitemaps_0.7.zip'">
	<h3><a id="download_link" href="http://signalkraft.com/media/sitemaps_0.7.zip">Download <strong>Sitemaps for Codeigniter</strong></a></h3>
	<p class="version">Version 0.7</p>
	<p class="license">Licensed under <a href="http://www.gnu.org/licenses/gpl-2.0.txt">GNU GPL v2</a>
</div>

<p>This library for the popular PHP framework <a href="http://codeigniter.com/">CodeIgniter</a> generates XML sitemaps and informs search engines and other webservices of new content for them to crawl.<p>

<p>With <a href="http://www.readwriteweb.com/archives/make_google_search_real-time_with_this_url_hack.php">live search around the corner</a> and a relatively new, yet widely adopted and open <a href="http://sitemaps.org/protocol.php">standard for Sitemaps</a>, now is the time to create a Sitemap for your CodeIgniter application!</p>

<h2>Important Features</h2>
<ul class="check">
	<li><strong>Easy to use:</strong> <a href="#example">See the example</a> to get started,</li>
	<li><strong>Tiny footprint:</strong> Only library and config are necessary,</li>
	<li><strong>Scalability:</strong> Split work load and update only when necessary (see <a href="#performance">a word about performance</a>),</li>
	<li><strong>Open standard:</strong> Follows the <a href="http://sitemaps.org/protocol.php">Sitemaps XML protocol 0.9</a>, compatible with any modern search engine,</li>
	<li><strong>Google, Yahoo, Bing &amp; Ask.com:</strong> By default this library uses <a href="http://www.sitemapwriter.com/notify.php">Sitemap Writer</a> to spread your sitemap (this can be changed in the config),</li>
	<li><strong>Sitemap Indexes:</strong> Build an index of all your sitemaps (see <a href="#sitemap_index">Sitemap Index</a>),</li>
	<li><strong>Autodiscovery:</strong> Web services will find your sitemap through robots.txt (see <a href="#autodiscovery">Autodiscovery</a>).</li>
</ul>

<p>This library is based on work of <a href="http://codeigniter.com/wiki/Google_Sitemaps/">Svetoslav Marinov</a> but performs quicker (objects were tossed in favor of arrays), supports a newer, non-proprietary standard and in my opinion fits the CodeIgniter philosophy much better (library versus plugin).</p>

<h2>Installation</h2>
<p>Download the library, extract the contents to your <em>system/application</em> folder. Modify the config file to suit your particular application then load and use the library as you would with any other. <a href="#example">See the example below for a sample controller</a>.

<a name="example"></a>
<h2>Example</h2>
<p>In this example we will assume you have a blog you wish to create a sitemap for. Your blog has a model “posts_model” that contains all the articles you have written.</p>
<div class="codeCaption">application/controllers/sitemap.php</div>
<pre><code>&lt;?php

class Sitemap extends Controller
{
	function Sitemap()
	{
		parent::Controller();
	}
	
	function index()
	{
		$this-&gt;load-&gt;model('posts_model');
		$this-&gt;load-&gt;library('sitemaps');
		
		$posts = $this-&gt;posts_model-&gt;get_posts();
		
		foreach($posts AS $post)
		{
			$item = array(
				&quot;loc&quot; =&gt; site_url(&quot;blog/&quot; . $post-&gt;slug),
				// ISO 8601 format - date("c") requires PHP5
				&quot;lastmod&quot; =&gt; date(&quot;c&quot;, strtotime($post-&gt;last_modified)),
				&quot;changefreq&quot; =&gt; &quot;hourly&quot;,
				&quot;priority&quot; =&gt; &quot;0.8&quot;
			);
			
			$this-&gt;sitemaps-&gt;add_item($item);
		}
		
		// file name may change due to compression
		$file_name = $this-&gt;sitemaps-&gt;build(&quot;sitemap_blog.xml&quot;);

		$reponses = $this-&gt;sitemaps-&gt;ping(site_url($file_name));
		
		// Debug by printing out the requests and status code responses
		// print_r($reponses);

		redirect(site_url($file_name));
	}
}</code></pre>
<p>Call the controller and you should be redirected to your freshly built sitemap.</p>
<p>If you want to see HTTP response codes and the requests that were sent by the ping function, uncomment the <code>print_r</code> line in the example.</p>

<p>Of course you will want to update your sitemap frequently — on *nix operating systems a cronjob stands to reason. To update every ten minutes, use <code>crontab -e</code> and add this line:</p>

<div class="codeCaption">crontab –e</div>
<pre><code># m h  dom mon dow   command
*/10  *  *  *  *  /usr/bin/wget -q -O /dev/null http://www.example.com/sitemap</code></pre>

<a name="performance"></a>
<p>With large sites and frequent changes, consider generating only when creating, updating or deleting. In this case arranging your data into several sitemaps can further reduce work load. For example a sitemap with all your blog posts can be updated seperately from a sitemap containing your infrequently modified static pages.</p>

<p>To stitch all those sitemaps together into something the search engines can handle you will need another type of file, the sitemap index:</p>

<a name="sitemap_index"></a>
<h2>Sitemap Index</h2>
<p>Sitemap indexes are technically only needed if your sitemap exceeds 50,000 <span class="caps">URL</span>s or 10MB uncompressed file size  — whichever comes first. In this case you need to build several smaller sitemaps and index their location in a seperate file, the sitemap index. This file is then treated as a normal sitemap:</p>
<pre><code class="php">$sitemaps = array(
	array(&quot;loc&quot; =&gt; site_url(&quot;sitemap_posts.xml.gz&quot;), &quot;lastmod&quot; =&gt; date(&quot;c&quot;)),
	array(&quot;loc&quot; =&gt; site_url(&quot;sitemap_pages.xml.gz&quot;))
);

$index_file_name = $this-&gt;sitemaps-&gt;build_index($sitemaps, &quot;sitemap_index.xml&quot;);
$reponses = $this-&gt;sitemaps-&gt;ping(site_url($index_file_name));

redirect(site_url($index_file_name));</pre></code>

<p>For the sake of completeness I should mention that your sitemap index musn’t exceed 50,000 sitemaps or 10MB uncompressed file size. If you manage to hit this 2.5 * 10<sup>9</sup> URL limitation on CodeIgniter you should probably pause for a minute and contemplate just what got you into this position and how you may avoid it in the future.</p>

<a name="autodiscovery"></a>
<h2>Autodiscovery</h2>

<p>Autodiscovery is a neat feature by which other web services can find your sitemap. You just need to create a <code>robots.txt</code> file in the root directory of your website (http://www.example.com/robots.txt) containing the following line:</p>

<div class="codeCaption">robots.txt</div>
<pre><code>Sitemap: http://www.example.com/sitemap.xml</code></pre>
<p>If you already have a <code>robots.txt</code>, put this directive anywhere; it is independent of <code>user-agent</code>.

<p>For further information visit the <a href="http://sitemaps.org/protocol.php">Sitemaps XML Protocol website</a> or look at the source code of this library. All functions and parameters are documented.</p>

<h2>Changelog</h2>
<ul style="list-style: none;">
<li>Version 0.7:
<ul>
<li>Fixed a bug in add_item_array()</li>
<li>Improved documentation</li>
</ul>
</li>
<li>Version 0.6: 
<ul>
<li>Added sitemap_index function</li>
</ul>
</li>
<li>Version 0.5:
<ul>
<li>First public release</li>
</ul>
</li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://signalkraft.com/sitemaps-for-codeigniter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Black Axe</title>
		<link>http://signalkraft.com/black-axe</link>
		<comments>http://signalkraft.com/black-axe#comments</comments>
		<pubDate>Sun, 15 Mar 2009 21:39:09 +0000</pubDate>
		<dc:creator>Philipp</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wp.signalkraft.com/black-axe</guid>
		<description><![CDATA[The Black Axe clothing label has a sale going on.]]></description>
			<content:encoded><![CDATA[<p>The clothing label <a href="http://theblackaxe.bigcartel.com/">“The Black Axe” has a sale going on right now</a>. You should probably check it out, black-on-black print never looked better.</p>
<a href="http://theblackaxe.bigcartel.com/" class="gallery"><img src="/media/images/black_mock.jpg" width="390" height="320" /><img src="/media/images/bv_mock.jpg" width="390" height="320" /></a>]]></content:encoded>
			<wfw:commentRss>http://signalkraft.com/black-axe/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
