<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Fuel Your Coding</title>
	
	<link>http://fuelyourcoding.com</link>
	<description />
	<lastBuildDate>Thu, 21 Jan 2010 17:01:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/fuelyourcoding" /><feedburner:info uri="fuelyourcoding" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><feedburner:emailServiceId>fuelyourcoding</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>jQuery Plugin Design Patterns: Part I</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/WqIp9mm1NHY/</link>
		<comments>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 18:21:06 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Plugins / Add-Ons]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=798</guid>
		<description><![CDATA[jQuery plugins come in all shapes and sizes. They perform very simple or very complex tasks depending on their intended use. When it comes time for you to design your own plugin, its really important to understand what patterns other developers use and what will best suits your needs.
As a side note, I have built [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/">jQuery Plugin Design Patterns: Part I</a></p>
]]></description>
			<content:encoded><![CDATA[<p>jQuery plugins come in all shapes and sizes. They perform very simple or very complex tasks depending on their intended use. When it comes time for you to design your own plugin, its really important to understand what patterns other developers use and what will best suits your needs.</p>
<p>As a side note, I have built a number of plugins for my own projects and client work that will <em>never be released</em>. The jQuery community needs to stop thinking of plugins only as releasable, open-source projects, and start thinking of them instead as a reusable pieces of code that can help optimize and <a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">DRY</a> up a complex website. Take this little plugin as an example:</p>
<pre class="brush: jscript;">
$.fn.notice = function(){
    return this.slideDown(500).delay(4000).slideUp(500);
}
</pre>
<p>It simply abstracts the animation for displaying a notice (using jQuery 1.4). Would I ever release this on an open source site? Of course not! But it is still a fully functioning jQuery plugin that can be used over and over throughout a website.</p>
<h2>Design Pattern Series Overview</h2>
<ul>
<li>Basics &amp; Structure (this article)</li>
<li>Options &amp; Updating</li>
<li>Callbacks &amp; Custom Events</li>
<li>Misc. General Practices</li>
</ul>
<h2>Basics</h2>
<h3>Filename</h3>
<p>Every jQuery plugin sits in its own JS file, and is normally named using the following pattern:</p>
<pre class="brush: plain;">
jquery.pluginname.js
jquery.pluginname.min.js
</pre>
<p>Released plugins often also have a version number:</p>
<pre class="brush: plain;">
jquery.pluginname-1.3.js
jquery.pluginname-1.3.min.js
</pre>
<p>If you end up building a lot of plugins for your website, consider also including a namespace to keep all your files together (And of course you would combine and minify them for production, right?):</p>
<pre class="brush: plain;">
jquery.mysite.pluginname.js
jquery.mysite.pluginname.js
</pre>
<h3>Basic File Layout</h3>
<p>After any comments you choose to put at the top of your file, the very next thing you should have is a self executing anonymous function that will actually wrap your entire plugin. Say what!? Don&#8217;t worry, you have seen it before, and it looks like this:</p>
<pre class="brush: jscript;">
(function($){

   ... code here ...

})(jQuery);
</pre>
<p>This gives your plugin a private scope to work in, and also allows your plugin to be used with <code>$.noConflict</code> mode without creating a problem. By passing <tt>jQuery</tt> into the function, the <tt>$</tt> will equal jQuery <em>inside</em> the function even if <code>$</code> means something different outside your plugin.</p>
<h2>Structure</h2>
<p>There are three basic structures you will see when you look at released plugins:</p>
<h3>Contained Function</h3>
<p>In this structure, (almost) all the code to run your plugin is contained within the function used to call your plugin. This is the most common format:</p>
<pre class="brush: jscript;">
(function($){

   $.fn.myPlugin = function(){
      return this.each(function(){
         // do something
      });
   }

})(jQuery);
</pre>
<p>You <strong>should</strong> use this this structure when you are writing a simple plugin that acts once upon the jQuery result set on each execution. For complex plugins that need to maintain an adjustable state, you should consider the &#8220;Class and Function&#8221; structure.</p>
<h3>Class and Function</h3>
<p>In this structure, a class is used and an instance is created for each DOM element in the result set. You may see these objects attached in some way to the DOM elements they modify:</p>
<pre class="brush: jscript;">
(function($){
   var MyClass = function(el){
       var $el = $(el);

       // Attach the instance of this object
       // to the jQuery wrapped DOM node
       $el.data('MyClass', this);
   }

   $.fn.myPlugin = function(){
      return this.each(function(){
         (new MyClass(this));
      });
   }

})(jQuery);
</pre>
<p>You <strong>should</strong> use this structure if you need to be able to access the object later that is associated with a DOM element. It is far easier to attach a single object vs several key/value pairs using the <tt>data()</tt> method. In this approach, you can access the object by calling <tt>$('selector').data('MyClass')</tt>. This functions more like a widget and is a plugin that maintains state and can adjust its state on the fly (Learn how in the next article.).</p>
<p><em><strong>Note: </strong> Widget Factory: The next release of jQuery UI is going to see the addition of a Widget Factory that will be designed to specially assist in developing widget-like plugins. </em></p>
<h3>Extend</h3>
<p>In my opinion, this is the least idiomatic way to create a jQuery plugin. It uses the <tt>jQuery.fn.extend</tt> method instead of <tt>jQuery.fn.pluginName</tt>:</p>
<pre class="brush: jscript;">
(function($){

   $.fn.extend({
     myPlugin: function(){
      return this.each(function(){
         // do something
     },
     myOtherPlugin: function(){
      return this.each(function(){
         // do something
     }
   });

})(jQuery);
</pre>
<p>You will find this structure helpful if you need to add a <em>large number</em> of plugin methods to jQuery. I would contend, however, that if your plugin needs to add that many methods, there may be a better way to structure its implementation.</p>
<p>I feel the extend method is used more by programmers transitioning from other JS libraries. I personally find the simple <tt>$.fn.pluginName =</tt> structure to be easier to read, and more in line with what you will normally see in jQuery plugins.</p>
<h2>Up Next</h2>
<p>In the next part of this series, we will look at passing options and providing methods for updating settings and functionality after a plugin has been called.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/">jQuery Plugin Design Patterns: Part I</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=WqIp9mm1NHY:zlz0X0TXU9k:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=WqIp9mm1NHY:zlz0X0TXU9k:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=WqIp9mm1NHY:zlz0X0TXU9k:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=WqIp9mm1NHY:zlz0X0TXU9k:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=WqIp9mm1NHY:zlz0X0TXU9k:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=WqIp9mm1NHY:zlz0X0TXU9k:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=WqIp9mm1NHY:zlz0X0TXU9k:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=WqIp9mm1NHY:zlz0X0TXU9k:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=WqIp9mm1NHY:zlz0X0TXU9k:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=WqIp9mm1NHY:zlz0X0TXU9k:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=WqIp9mm1NHY:zlz0X0TXU9k:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/WqIp9mm1NHY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/jquery-plugin-design-patterns-part-i/</feedburner:origLink></item>
		<item>
		<title>jQuery Enlightenment: Book Review and Giveaway (Winners Announced!)</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/FT-Up1eU2s4/</link>
		<comments>http://fuelyourcoding.com/jquery-enlightenment-book-review-and-giveaway/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 20:04:58 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Books / Magazines]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=782</guid>
		<description><![CDATA[Winners Announced
I was really happy to see so much participation in this giveaway! After seeing how many people entered, I was feeling really bad that only one of them would leave with a copy of the book. I talked to Cody, and he graciously provided two more free copies so we can award a total [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/jquery-enlightenment-book-review-and-giveaway/">jQuery Enlightenment: Book Review and Giveaway (Winners Announced!)</a></p>
]]></description>
			<content:encoded><![CDATA[<h2>Winners Announced</h2>
<p>I was really happy to see so much participation in this giveaway! After seeing how many people entered, I was feeling really bad that only one of them would leave with a copy of the book. I talked to Cody, and he graciously provided two more free copies so we can award a total of three books! I randomly picked three winners (using <a href="http://random.org">Random.org</a>) and am happy to announce the following winners:</p>
<ul>
<li>Brad Rhine (<a href="http://truetech.org">truetech.org</a>)</li>
<li>Mila</li>
<li>Geoff Woodburn (<a href="http://woodburndesigns.com">woodburndesigns.com</a>)</li>
</ul>
<h2>Book Review</h2>
<p>Late in 2009, <a href="http://www.codylindley.com">Cody Lindley</a> published a PDF book on jQuery titled <a href="http://jqueryenlightenment.com">jQuery Enlightenment</a>. Today we are presenting our view of the book as well as offering a free copy to one lucky reader.</p>
<p><img class="alignnone size-full wp-image-792" title="jqueryen" src="http://fuelyourcoding.com/files/jqueryen.jpg" alt="jqueryen" width="600" height="300" /></p>
<h2>About The Author</h2>
<p>Cody Lindley is a core team member of the <a href="http://jquery.com">jQuery</a> project, and the original developer of the well known Thickbox plugin for jQuery. I had the pleasure of meeting and listening to Cody present at the jQuery Conference last year in Boston. He describes himself on his website:</p>
<blockquote><p>Today I am a Christian, husband, son, brother, professional Web developer, and outdoor enthusiast. I spend a majority of my time sleeping and working, but who doesn’t? In between the daily routines of the average American, I desire an existence that entails a relationship with God, my family, and nature. I would like to consider myself a bookworm (a novice theologian at best), but truth be told, I simply enjoy watching movies and playing xBox way too much. I guess I also have the luxury of pursuing my profession as a personal passion. Yes, I often work even when I am not at work.</p></blockquote>
<h2>Overview</h2>
<p>jQuery Enlightenment is a different type of book than I am used to seeing in the tech field. A list of what it is <em>not</em> might help shed light on what I mean. It is not documentation, a tutorial/walkthrough, or just conceptual material. jQuery Enlightenment is an amazingly clear montage of principals and code samples every jQuery developer needs to know grouped by topic. Cody covered topics both basic and profound throughout the pages of the book.</p>
<p>I consider myself quite adept at using jQuery, but found myself constantly amazed at the things I was learning while reading this book.  Cody says it picks up where the jQuery documentation leaves off. I can see his point, but I think this book would be a better starting place for a new jQuery developer than even reading through the jQuery API site.</p>
<h2>Pros</h2>
<h3>Code Samples</h3>
<p><img class="alignnone size-full wp-image-783" title="code" src="http://fuelyourcoding.com/files/code.jpg" alt="code" width="568" height="104" /></p>
<p>Code samples make up over 70% of the book (rough estimation). The book is not written in an editorial way at all. It is about presenting what you need to know, demonstrating it with an example, and moving on. For this reason the book is an extremely fast read and perfect for reference on a day to day basis.</p>
<p>Possibly one of the neatest features of the book itself is that (almost) every code sample provided in the book has a link to the same code on JSBin.com. JSBin is an online playground for testing and demonstrating JavaScript, HTML, and CSS technologies. jQuery Enlightenment isn&#8217;t a flat reading experience, it allows you to immediately jump in and play with the code samples until everything makes sense.</p>
<h3>Additional Notes</h3>
<p><img class="alignnone size-full wp-image-784" title="notes" src="http://fuelyourcoding.com/files/notes.jpg" alt="notes" width="568" height="104" /></p>
<p>Many of the topics are followed by a little box titled &#8216;Notes&#8217;. I am glad Cody didn&#8217;t choose some cheesy title for these boxes, but &#8216;Notes&#8217; really does not sum up what they provide. You will find many undocumented (or hard to find) tips and tricks about the finer points of jQuery in these boxes. Skip over them at your own peril!</p>
<h3>No Fluff Quality</h3>
<p>Cody doesn&#8217;t waste any time on any of the topics presented in the book. The pattern used is simple: explain, demonstrate, move on. I personally will be using this book not just for reference, but for a quick read-through every few weeks to keep my jQuery senses sharp.</p>
<h2>Cons</h2>
<p>You will be hard pressed to find something negative to say about this book, and it wasn&#8217;t until I reached the end that I had one complaint about the content. The chapter on Ajax (Chapter 11) was far too short. Perhaps this is because the documentation is very clear, but I still wanted to learn more and have more examples to glean from. Perhaps the second edition of the book (which will cover jQuery 1.4) will provide more detail on jQuery&#8217;s AJAX implementation and associated methods.</p>
<h2>Conclusion</h2>
<p>I am confident new users and seasoned users alike will find much to learn in jQuery Enlightenment. After reading the book, my only concern is that I won&#8217;t remember all of the cool things I learned while reading it!</p>
<h2>Win a FREE Copy!</h2>
<p>Next Wednesday we will be selecting a winner to receive a free copy of jQuery Enlightenment. Entering the competition is easy!</p>
<p>Head over to <a href="http://jqueryenlightenment.com">jQuery Enlightenment</a> and quickly look through table of contents. Then, leave a comment below telling us what chapter you think you would learn the most from if you were to win the book. Only comments referencing one of the actual chapters in the book will be eligible to win. <strike>We will randomly select a winner next Wednesday and announce it here on the site.</strike>. <strong>Sorry, but the contest is over!</strong></p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/jquery-enlightenment-book-review-and-giveaway/">jQuery Enlightenment: Book Review and Giveaway (Winners Announced!)</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=FT-Up1eU2s4:yk-0a2Twr-s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=FT-Up1eU2s4:yk-0a2Twr-s:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=FT-Up1eU2s4:yk-0a2Twr-s:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=FT-Up1eU2s4:yk-0a2Twr-s:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=FT-Up1eU2s4:yk-0a2Twr-s:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=FT-Up1eU2s4:yk-0a2Twr-s:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=FT-Up1eU2s4:yk-0a2Twr-s:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=FT-Up1eU2s4:yk-0a2Twr-s:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=FT-Up1eU2s4:yk-0a2Twr-s:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=FT-Up1eU2s4:yk-0a2Twr-s:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=FT-Up1eU2s4:yk-0a2Twr-s:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/FT-Up1eU2s4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/jquery-enlightenment-book-review-and-giveaway/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/jquery-enlightenment-book-review-and-giveaway/</feedburner:origLink></item>
		<item>
		<title>Unconventional: CSS3 Link Checking</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/z0a-S8fJKjA/</link>
		<comments>http://fuelyourcoding.com/unconventional-css3-link-checking/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 19:50:24 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Concepts & Training]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=767</guid>
		<description><![CDATA[One of our regular writers Wess Cope lives by the principle that you should seek to push technology past its intended uses and beyond even its own limitations. From time to time we will be featuring unconventional uses of technology. Today, we look at unconventional CSS3:
The Problem
As a developer, you are rapidly building your newest [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/unconventional-css3-link-checking/">Unconventional: CSS3 Link Checking</a></p>
]]></description>
			<content:encoded><![CDATA[<p>One of our regular writers <a href="/about">Wess Cope</a> lives by the principle that you should seek to push technology past its intended uses and beyond even its own limitations. From time to time we will be featuring unconventional uses of technology. Today, we look at unconventional CSS3:</p>
<h2>The Problem</h2>
<p>As a developer, you are rapidly building your newest web creation. You start with the HTML, knowing full well you don&#8217;t have the hyperlinks you will need to complete the design. Nonetheless you put in:</p>
<pre class="brush: xml;">
&lt;ul id=&quot;nav&quot;&gt;
   &lt;li&gt;&lt;a href=&quot;/&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href=&quot;&quot;&gt;About&lt;/a&gt;&lt;/li&gt;
   &lt;li&gt;&lt;a href=&quot;&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
   ...
&lt;/ul&gt;
</pre>
<p>What seems like a long time later, you get to the point where you finish up your site for demoing or production. How do you quickly find all those empty links? Well, you could use a link checker&#8230; or, just use CSS3!</p>
<h2>CSS3 Solution</h2>
<p>Just paste this line to the end of your last included CSS file for a quick visual display:</p>
<pre class="brush: css;">
/* Find all links where an href is not provided */
html body a:not([href]), html body a[href='']  { background: red !important;}
</pre>
<p>Then open your site in modern browser that supports CSS3, and any empty link now has a background of red. Edit your HTML, and check the page again. When all the links are fixed, none will have a red background!</p>
<p>You can see for yourself by checking a quick demo:<br />
<a target="_blank" href="http://fuelbrand.s3.amazonaws.com/coding/unconventional-css3/styles-off.html">Standard Page</a> | <a target="_blank"  href="http://fuelbrand.s3.amazonaws.com/coding/unconventional-css3/styles-on.html">Page With CSS3 Link Checking</a></p>
<h2>Bonus: Testing Progressive Enhancement</h2>
<p>For mission critical functionality it is generally good practice to have a fallback for non JavaScript users. To test if your page has any JavaScript only code, add this rule to your CSS file after the rule we just added:</p>
<pre class="brush: css;">
/* Find all links where the href = # */
html body a[href='#'] { background: yellow !important;}
</pre>
<p>Next, disable JavaScript in your browser (In Firefox and Safari it is an option in your preferences.).</p>
<p>Now, any of those links you cleverly enhanced with JavaScript, but forgot to add a valid fallback URL, will show up with a yellow background. If an item truly has application <em>only</em> when JavaScript is enable, you should consider adding it dynamically with JavaScript.</p>
<h2>Variations</h2>
<p>As a leftover vestige from IE6 days, many developers use <tt>href='#'</tt> so signify an empty url (So the <tt>:hover</tt> pseudo selector will still work). If this is your case, you have two options: 1) Change your style going forward and use <tt>href=''</tt> to signify an empty URL and <tt>href='#'</tt> for JavaScript enhanced links. or 2) Use only the second CSS3 rule and change the color to Red.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/unconventional-css3-link-checking/">Unconventional: CSS3 Link Checking</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=z0a-S8fJKjA:RExd44aPuiA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=z0a-S8fJKjA:RExd44aPuiA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=z0a-S8fJKjA:RExd44aPuiA:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=z0a-S8fJKjA:RExd44aPuiA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=z0a-S8fJKjA:RExd44aPuiA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=z0a-S8fJKjA:RExd44aPuiA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=z0a-S8fJKjA:RExd44aPuiA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=z0a-S8fJKjA:RExd44aPuiA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=z0a-S8fJKjA:RExd44aPuiA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=z0a-S8fJKjA:RExd44aPuiA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=z0a-S8fJKjA:RExd44aPuiA:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/z0a-S8fJKjA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/unconventional-css3-link-checking/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/unconventional-css3-link-checking/</feedburner:origLink></item>
		<item>
		<title>Best of 2009 in the Coding Industry</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/a8c7eja07P0/</link>
		<comments>http://fuelyourcoding.com/best-of-2009/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 11:00:26 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Languages]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[best of 2009]]></category>
		<category><![CDATA[best of coding industry]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=710</guid>
		<description><![CDATA[Every year we see amazing technical advances and 2009 was no exception. Both Apple and Microsoft released new versions of their operating systems; pretty much every major browser, and some smaller ones, saw significant releases and improvements. New tools were released to assist developers as well as new books to increase the effectiveness of both [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/best-of-2009/">Best of 2009 in the Coding Industry</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Every year we see amazing technical advances and 2009 was no exception. Both Apple and Microsoft released new versions of their operating systems; pretty much every major browser, and some smaller ones, saw significant releases and improvements. New tools were released to assist developers as well as new books to increase the effectiveness of both new and seasoned developers alike. In this post we take a look at some of the highlights of 2009. In addition to featuring items you should already know about, I hope to present a few items you may have overlooked during the past year.</p>
<h2>Technologies</h2>
<p><a href="http://www.firerift.com"><img class="alignnone size-full wp-image-717" title="Firerift" src="http://fuelyourcoding.com/files/firerift.jpg" alt="Firerift" width="600" height="200" /></a></p>
<h3><a href="http://www.firerift.com">Firerift</a></h3>
<p>Firerift launched earlier this year as a completely new breed of Content Management Systems.  Firerift is, at its core, a <a href="http://json.org">JSON</a> server with an amazing user interface. The mind behind Firerift <a href="http://drewwilson.com">Drew Wilson</a> refers to it as a Client side CMS. All the tagging is done using CSS classes and valid markup. Released along with Firerift was Titan, an open source JSON templating engine built on top of <a href="http://jquery.com">jQuery</a>. Firerift is a glimpse into the future of highly dynamic, AJAX powered websites.</p>
<p><a href="http://lesscss.org/"><img class="alignnone size-full wp-image-723" title="less" src="http://fuelyourcoding.com/files/less.jpg" alt="less" width="600" height="200" /></a></p>
<h3><a href="http://lesscss.org/">LESS Framework</a></h3>
<p>The LESS framework for CSS provides simplified execution of advanced CSS. With support for variables, mixins, nested rules and mathematical operations. LESS lives up to its name by letting you write shorter, optimized CSS. Though it is packaged as a <a href="http://www.ruby-lang.org">Ruby</a> gem, it can be used to prepare CSS files for any technology, even straight HTML/CSS websites. Since it uses CSS syntax, it&#8217;s as easy as renaming your <tt>.css</tt> files to <tt>.less</tt> and parsing through the LESS engine.</p>
<p><a href="http://buddypress.org/"><img class="alignnone size-full wp-image-713" title="buddy_press" src="http://fuelyourcoding.com/files/buddy_press.jpg" alt="buddy_press" width="600" height="200" /></a></p>
<h3><a href="http://buddypress.org/">BuddyPress</a></h3>
<p>BuddyPress is an amazing addition to WordPress MU (soon to be merged into WordPress core) that turns WPMU into an open-source social networking platform. From their website:</p>
<blockquote><p>BuddyPress is a suite of WordPress plugins and themes, each adding a distinct new feature. BuddyPress contains all the features you’d expect from WordPress but aims to let members socially interact.</p></blockquote>
<p><img class="alignnone size-full wp-image-712" title="browsers" src="http://fuelyourcoding.com/files/browsers.jpg" alt="browsers" width="600" height="200" /></p>
<h3>New Browsers All Around</h3>
<p>This year saw major advances in pretty much all the major browsers. <a href="http://www.apple.com/safari/">Safari 4</a> saw extreme speed increases in its JavaScript performance as well as support for advanced CSS3 properties. <a href="http://www.mozilla.com/en-US/firefox/firefox.html">Firefox</a> saw many of the same improvements and support with the 3.5 release.  Even the browser developers love to hate saw significant improvements with the release of Internet Explorer 8. (Sadly, still no <tt>border-radius</tt> support!). <a href="http://www.google.com/chrome">Google Chrome</a> seems to see major version number updates much faster than the other browsers, but of significant importance was the final release of a slightly limited Chrome for Mac Beta. <a href="http://opera.com">Opera</a> continued to improve and innovate their browser as well, but I think a great change this year was that Opera got an icon facelift and the dreaded drop shadow on the &#8220;O&#8221; is gone!</p>
<h2>Notable Events</h2>
<p><a href="http://blog.jquery.com/2009/12/03/jquery-joins-the-software-freedom-conservancy/"><img class="alignnone size-full wp-image-722" title="jquery" src="http://fuelyourcoding.com/files/jquery.jpg" alt="jquery" width="600" height="200" /></a></p>
<h3><a>jQuery Joins The Software Freedom Conservancy</a></h3>
<p>The jQuery team has been planning for a while to join the <a href="http://conservancy.softwarefreedom.org/">Software Freedom Conservancy</a> to protect the jQuery project, open the door for future growth, as well as to move the copyright from John Resig&#8217;s own name into the Conservancy&#8217;s name. From the <a href="http://conservancy.softwarefreedom.org/overview/">overview page</a>:</p>
<blockquote><p>One of the principal benefits of joining the Conservancy is that member projects get all the protections of being a corporate entity without actually having to form and maintain one. These benefits include, most notably, the ability to collect earmarked project donations and protection from personal liability for the developers of the project.</p></blockquote>
<p>The jQuery team made the first step this year by joining the Conservancy as planned, and are now working to move the copyright as well.</p>
<p><a href="http://fixoutlook.org/"><img class="alignnone size-full wp-image-718" title="fixoutlook" src="http://fuelyourcoding.com/files/fixoutlook.jpg" alt="fixoutlook" width="600" height="200" /></a></p>
<h3><a>Fix Outlook</a></h3>
<p>A great movement from the guys over at <a href="http://campaignmonitor.com">Campaign Montior</a> launched <a href="http://fixoutlook.org">Fix Outlook</a> as a web campaign to make Microsoft aware of how many people disliked the limited email rendering engine in Office 2005 and newer. The campaign saw over 20,000 tweets in the first 24 hours! Microsoft at first responded rather negatively, then changed face a bit and became very thankful of the effort raised by the website. <a href="http://www.campaignmonitor.com/blog/post/2873/fixoutlook-retrospective/">You can read the full account</a> for more details.</p>
<h2>Books</h2>
<p><a href="http://digwp.com/book/"><img class="alignnone size-full wp-image-715" title="digging" src="http://fuelyourcoding.com/files/digging.jpg" alt="digging" width="600" height="200" /></a></p>
<h3><a href="http://digwp.com/book">Digging Into WordPress</a></h3>
<p>Digging into WordPress is a fantastic new book by <a href="http://chriscoyier.net">Chris Coyier</a> and <a href="http://digwp.com/jeff-starr/">Jeff Starr</a>. It is only available currently as a PDF book, but a printed version is coming soon. Written in an extremely down to earth manner, this book will provide useful information for anyone looking to take WordPress to the next level. This isn&#8217;t a book solving hypothetical problems: the authors only present techniques they have used themselves.</p>
<p><a href="http://jqueryenlightenment.com/"><img class="alignnone size-full wp-image-721" title="jquery_enlightenment" src="http://fuelyourcoding.com/files/jquery_enlightenment.jpg" alt="jquery_enlightenment" width="600" height="200" /></a></p>
<h3><a href="http://jqueryenlightenment.com">jQuery Enlightenment</a></h3>
<p>Written by jQuery core team member <a href="http://codylindley.com">Cody Lindley</a>, jQuery Enlightenment picks up where the <a href="http://docs.jquery.com/Main_Page">jQuery docs</a> leave off. The book is probably 80% code examples and 20% explanation. This is a no fluff, crystal clear presentation of intermediate to advanced jQuery techniques, though I think even beginners would learn a lot through reading this PDF book. An additional innovative feature that I hope other book writers pick up is that almost every code example is linked to a live example on <a href="http://jsbin.com">JSBin.com</a> so you can actually play with his examples, even changing the code, to see how they work.</p>
<h2>Operating Systems</h2>
<p><a href="http://microsoft.com/windows/windows-7/"><img class="alignnone size-full wp-image-727" title="windows7" src="http://fuelyourcoding.com/files/windows7.jpg" alt="windows7" width="600" height="200" /></a></p>
<h3><a href="http://microsoft.com/windows/windows-7/">Windows 7</a></h3>
<p>After nothing less than a PR nightmare with Windows Vista, Microsoft released a fantastic new operating system this year in Windows 7. Far more stable than its predecessor, Windows 7 takes many of the principles and innovations introduced with Vista, but makes them both useable and reliable to users of Windows 7.</p>
<p><a href="http://apple.com/macosx/"><img class="alignnone size-full wp-image-726" title="snow_leopard" src="http://fuelyourcoding.com/files/snow_leopard.jpg" alt="snow_leopard" width="600" height="200" /></a></p>
<h3><a href="http://apple.com/macosx">Snow Leopard</a></h3>
<p>The innovative and trendy OS for Macintosh computers saw an upgrade this year with the release of Snow Leopard. As its name indicates, this OS is not that different an animal from the previous release of OS X (Leopard). Maintaining the same look and feel, Snow Leopard introduced many innovated technology features to further speed up the already finely tuned Mac line of computers. This has to be the first time in history that the install of a new version of an operating system actually gave you <strong>back</strong> 7GB of hard drive space!</p>
<p><a href="http://www.apple.com/iphone/softwareupdate/"><img class="alignnone size-full wp-image-720" title="iphone" src="http://fuelyourcoding.com/files/iphone1.jpg" alt="iphone" width="600" height="200" /></a></p>
<h3><a href="http://www.apple.com/iphone/softwareupdate/">iPhone 3.0</a></h3>
<p>In the third version of the popular OS in use on iPhones and iPod Touches, users finally were allowed to Cut, Copy, and Paste! In addition, Multimedia Messaging (MMS), Spotlight Search, Voice Memos and Voice Dialing were also introduced. From a developers perspective, Apple opened up over 1,000 new API&#8217;s to allow iPhone developers even more freedom and power in their development process.</p>
<p><a href="http://developer.android.com/sdk/android-2.0-highlights.html"><img class="alignnone size-full wp-image-711" title="android" src="http://fuelyourcoding.com/files/android.jpg" alt="android" width="600" height="200" /></a></p>
<h3><a href="http://developer.android.com/sdk/android-2.0-highlights.html">Android 2.0</a></h3>
<p>For those that prefer an alternative to the Apple iPhone, many users have gravitated to the Android phones. This year saw an upgrade to the Android 2.0 OS and several UI and functional enhancements. Support for Exchange accounts, Combined Inboxes, and Macro Focus and White Balance for the Camera were all features added in this release.</p>
<h2>Web Tools</h2>
<p><a href="http://builditwith.me"><img class="alignnone size-full wp-image-714" title="builditiwthme" src="http://fuelyourcoding.com/files/builditiwthme.jpg" alt="builditiwthme" width="600" height="200" /></a></p>
<h3><a href="http://builditwith.me">Build It With Me</a></h3>
<p>Some developers can do everything themselves from marketing, to design, to development. The rest of us would rather work on the part of the project we love, and leave the rest to someone better suited for the job. BuildItWith.me is the goto place to meet other developers that either have ideas or time on their hands to work on your ideas. Form new partnerships, find great projects to work on, all within the stylish interface of BuildItWith.me. I love their tag line: &#8220;Skip the funding.&#8221;</p>
<p><a href="http://www.noteableapp.com"><img class="alignnone size-full wp-image-725" title="noteable" src="http://fuelyourcoding.com/files/noteable.jpg" alt="noteable" width="600" height="200" /></a></p>
<h3><a href="http://www.noteableapp.com">Noteable App</a></h3>
<p>Noteable provides a great way for web developers to seek responses from their clients during the design process. Simply use one of the provided tools to make a screenshot of the a web page you are working on, and send it to your client for approval. The client can draw on the screenshot and make notes, all through a simple web interface. If you are a developer that works remotely from your clients, this service might be just what you are looking for.</p>
<h2>Flagrant Self-Promotion</h2>
<p><a href="http://downloadify.info"><img class="alignnone size-full wp-image-716" title="downloadify" src="http://fuelyourcoding.com/files/downloadify.jpg" alt="downloadify" width="600" height="200" /></a></p>
<h3><a href="http://downloadify.info">Downloadify</a></h3>
<p>This year saw the release of Flash 10 and with it, the support for client-side file generation and download. Why is this important? Now developers can make web applications that can run fully in the browser, including file saving capabilities, without a round trip to the server. As a personal project, I built and released <a href="http://downloadify.info">Downloadify</a> to provide a JavaScript bridge to this amazing Flash functionality. Since the alternate server methods (dataURIs and IE functions) are all prone to usability problems, Downloadify provides a nice simple way to repurpose client side data and turn it into a savable file.</p>
<h2>WANT MORE?</h2>
<p><a href="http://droplr.com/3Hbt"><img class="alignleft size-full wp-image-1689" title="network-best-of" src="http://www.fuelyourapps.com/files/network-best-of.png" alt="network-best-of" width="600" height="137" /></a></p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/best-of-2009/">Best of 2009 in the Coding Industry</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=a8c7eja07P0:RaiO2pGeMsY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=a8c7eja07P0:RaiO2pGeMsY:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=a8c7eja07P0:RaiO2pGeMsY:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=a8c7eja07P0:RaiO2pGeMsY:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=a8c7eja07P0:RaiO2pGeMsY:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=a8c7eja07P0:RaiO2pGeMsY:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=a8c7eja07P0:RaiO2pGeMsY:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=a8c7eja07P0:RaiO2pGeMsY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=a8c7eja07P0:RaiO2pGeMsY:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=a8c7eja07P0:RaiO2pGeMsY:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=a8c7eja07P0:RaiO2pGeMsY:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/a8c7eja07P0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/best-of-2009/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/best-of-2009/</feedburner:origLink></item>
		<item>
		<title>Interview with Wess Cope, Wattz.net</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/RsBVm2RFnBg/</link>
		<comments>http://fuelyourcoding.com/interview-with-wess-cope-wattz-net/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 16:41:29 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Featured Developers]]></category>
		<category><![CDATA[Interviews]]></category>
		<category><![CDATA[developers]]></category>
		<category><![CDATA[interview]]></category>
		<category><![CDATA[programmers]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=694</guid>
		<description><![CDATA[I am excited to present this developer interview with programmer Wess Cope. Wess is a regular contributor here on Fuel Your Coding and so this interview was a great opportunity for us to learn more about what makes Wess tick.

Did you go to school for programming? How did you get started in this field?
I am [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/interview-with-wess-cope-wattz-net/">Interview with Wess Cope, Wattz.net</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I am excited to present this developer interview with programmer Wess Cope. Wess is a regular contributor here on Fuel Your Coding and so this interview was a great opportunity for us to learn more about what makes Wess tick.</p>
<h3><a href="http://fuelyourcoding.com/files/wess-header.jpg"><img class="alignnone size-full wp-image-703" title="wess-header" src="http://fuelyourcoding.com/files/wess-header.jpg" alt="wess-header" width="600" height="150" /></a></h3>
<h3><strong>Did you go to school for programming? How did you get started in this field?</strong></h3>
<p>I am a self taught programmer. I guess you could say I fell into the field when I was eight years old. I learned to program, well, mimic on a Commodore 128. I just typed in the code examples, then I changed things here and there and watched to see how it affected the program. I attended the Air Force Academy for electronic engineering and became an encryption programmer in the Air Force.</p>
<p>When I really started getting into the web development field, it was actually as a design and UI guy, not a programmer. I already knew how to program in C++ and Java, but not PHP. A friend of mine turned me on to the backend technologies, and I transitioned into the field of backend programming. I didn&#8217;t lose my connection to design and UI as fell deeper into the world of programming. On a side note, back in 1999 I really liked javascript&#8230; which if you remember is when most people didn&#8217;t like it at all!</p>
<p>Now I program all the time. Literally all the time. I normally program in five different languages all day at work, then do it all over again in the evenings. I don&#8217;t watch TV, I program.</p>
<h3><strong>It seems you like learning a lot about new technologies. Why is that?</strong></h3>
<p>Yes! Its actually a big joke with my family and friends. When Google announced &#8216;Go&#8217;, my brother-in-law called me right up and asked if I knew how to program with it yet. Anytime a new language comes out, I make a point of downloading it and building an application so I can understand how it works. It is really important to me to have a working knowledge of a technology. Then, when it comes up in a conversation I am not just speaking on hearsay. I have actually used it, so I can be more informed. It&#8217;s really all about dominance in arguments. :)</p>
<h3><strong>How would you recommend someone pick up an additional programming language?</strong></h3>
<p>I always recommend the same thing to anyone wanting to pick up a new language. Program something common with it. What I mean by common is something you know how to build in another language. For instance, whenever I learn a new technology I always build a user management app or a todo list app. The methodologies never change with those apps even though the technologies change. By building the same thing over and over with different technologies, I can more accurately compare them to each other. It helps me really learn the language. Hello World apps don&#8217;t show you what is really going on with the language.</p>
<h3><strong>Do you prefer physical books or searching for the information on the Internet?</strong></h3>
<p>I love books. I read a technical manual a month. I go through every step, try every example. When I am picking up a new language, I tell my brain I have never programmed before. Even when reading about MVC, I pretend I have never heard it before. Since each company handles it a little differently, I don&#8217;t pretend to understand how that company views it. When working through the examples, I never copy and paste; I type it all out. Even when I write tutorials, I often use screen-shots instead of easily copied code. I know good and well that if a programmer types each piece of code he will be less likely to forget what he learned. If all else fails, I will go to the internet for answers.</p>
<h3><strong>How do you get a personal or work project from idea to completion?</strong></h3>
<p>I try to crush goals quickly. If you set a milestone that is so large it overwhelms you, it will slow you down. Set a small goal, hit it, then do something else on a <em>different</em> project and with a <em>different</em> language. Switching between projects and languages keeps you from getting burned out. None of my to do lists on a project have more than 4 or 5 items. This is essential to fight burnout. When you fight burnout, you keep yourself happy. Plus  switching languages helps you stay very adaptable.</p>
<p>I have also found that feature creep comes from not stopping when your five tasks are done. When you finish what you set out to do, don&#8217;t look at it as being half complete. You are done&#8230; stop working on it. If you don&#8217;t, you will kill your own motivation. The big picture is beautiful, but don&#8217;t ruin it because a single leaf isn&#8217;t quite as nice as you imagined it.</p>
<h3><strong>Its your hobby, its your work. What else do you do when you aren&#8217;t programming?</strong></h3>
<p>I build furniture. I Build computer desks. As my needs change, so does my desk. As my languages change, my desk changes. I also spend time with my family. When I get home from work, three hours every night is family time.</p>
<p>I enjoy rock climbing and kayaking, but my current hobbies are really golfing and salt water fishing. However, sometimes I just like driving around and seeing how people interact with each other. I get a lot of inspiration for things I build by watching people interact.</p>
<p>Best thing sometimes is to stop and see the world for what it is. Not thinking about programming, but sitting with the family and enjoying life. Clearing your brain like that helps you get ready to code when you need it. I have never met a really stressed out programmer who writes really good code.</p>
<h3><strong>Thank you so much for this interview! What advice can you leave us with?</strong></h3>
<p>Push the limits of the technology you are using to the edge. Push it to where it shouldn&#8217;t even be functioning any more. An example of pushing the bounds is the <a href="http://cappuccino.org/" target="_blank">Cappuccino framework</a>. It is pushing javascript to the edge of what it should even be able to do. It completely blows my mind. Its the same thing Objective-C did to C. They broke the bounds of what the browser is capable of.</p>
<p>If you don&#8217;t think you can push the boundaries any further, then break them entirely. Use research to see how other people are using technologies in combination with out-of-the-box thinking. See how they are applying to to solve problems. Keep pushing the envelope.</p>
<h3><strong>How can our readers get in touch with you? Do you mind people connecting with you?</strong></h3>
<p>I love interacting with people! I am almost always on Freenode in one of the developer channels. I can be reached on AIM by my screen name: wattzilla. Of course my <a href="http://twitter.com/wattzilla">Twitter account</a> is another great way to get in touch with me. I welcome any and all contact, so look me up!</p>
<p><em>Note: </em><em>This interview has been adapted to a question and answer format from my much more relaxed interview with Wess last week.</em></p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/interview-with-wess-cope-wattz-net/">Interview with Wess Cope, Wattz.net</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=RsBVm2RFnBg:i21DUwecwy8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=RsBVm2RFnBg:i21DUwecwy8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=RsBVm2RFnBg:i21DUwecwy8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=RsBVm2RFnBg:i21DUwecwy8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=RsBVm2RFnBg:i21DUwecwy8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=RsBVm2RFnBg:i21DUwecwy8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=RsBVm2RFnBg:i21DUwecwy8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=RsBVm2RFnBg:i21DUwecwy8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=RsBVm2RFnBg:i21DUwecwy8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=RsBVm2RFnBg:i21DUwecwy8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=RsBVm2RFnBg:i21DUwecwy8:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/RsBVm2RFnBg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/interview-with-wess-cope-wattz-net/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/interview-with-wess-cope-wattz-net/</feedburner:origLink></item>
		<item>
		<title>JavaScript Can Learn: Now Teach It Tricks!</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/VnRa1eOpj1w/</link>
		<comments>http://fuelyourcoding.com/javascript-can-learn-now-teach-it-tricks/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 07:00:34 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Concepts & Training]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[extending]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=672</guid>
		<description><![CDATA[When you do a lot of development with backend technologies, it can be frustrating to then move to the front end and feel like you are using a completely different syntax. One thing I really miss is the helper methods, especially when using Ruby on Rails on the server. Little helpers like titleize() or downcase() [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/javascript-can-learn-now-teach-it-tricks/">JavaScript Can Learn: Now Teach It Tricks!</a></p>
]]></description>
			<content:encoded><![CDATA[<p>When you do a lot of development with backend technologies, it can be frustrating to then move to the front end and feel like you are using a completely different syntax. One thing I really miss is the helper methods, especially when using Ruby on Rails on the server. Little helpers like <tt>titleize()</tt> or <tt>downcase()</tt> get replaced in javascript by a custom function and <tt>toLowerCase()</tt> respectively. You don&#8217;t have to feel lost anymore! There is a way you can extend the native objects found in JavaScript to make your environment feel a little more like &#8220;home.&#8221;</p>
<p>This is accomplished by using the prototype object. Each native object in JavaScript includes a prototype object. Don&#8217;t get this confused with the PrototypeJS framework&#8230; the prototype object is a way to extend <em>all</em> objects that have inherited from the base object you extended. You can easily extend the prototype object by adding functions to it like this:</p>
<pre class="brush: jscript;">
Object.prototype.functionName = function(){

}
</pre>
<p>You can then call them directly:</p>
<pre class="brush: jscript;">
var obj = new Object();
obj.functionName();
</pre>
<p>There are a number of advanced uses of the prototype object, but this is the important thing to remember: any function added to the prototype of an object is available on any object that inherits from it. So if you extend the prototype on the Number object, all numbers will have access to the new function; if you extend the Array object, all arrays can access your custom function. You only use the <tt>prototype.functionName</tt> syntax when declaring the new function, not when calling it.</p>
<p>Enough theory, lets see some (somewhat) practical uses:</p>
<p>Do you find yourself capitalizing a lot of words in a particular JavaScript app? Just add a <tt>capitalize</tt> method to the String object.</p>
<pre class="brush: jscript;">
String.prototype.capitalize = function(){
  if(this.length == 0) return this;
  return this[0].toUpperCase() + this.substr(1);
}
</pre>
<p>Now you can capitalize any string in your application by calling <tt>"lower".capitalize()</tt> and get <tt>"Lower"</tt> in return. Since it returns a string, you could chain it with any other function you can execute on a string.</p>
<p>Do you always find yourself forgetting you can call Number(&#8221;25&#8243;) to turn a string into a number? Just add a <tt>toNumber()</tt> function to the String prototype:</p>
<pre class="brush: jscript;">
String.prototype.toNumber = function(){
  return Number(this);
}

If you need to split large JSON arrays into groups of two or three each, you could extend the Array object like this:

[js]
Array.prototype.inGroupsOf = function(num){
	var ret = [],
		length = this.length,
		groups = Math.ceil(length / num);

	for(var i = 0; i &lt; groups; i++){
		var start = i * num,
			end   = start + num;

		ret.push(this.slice(start, end))
	}
	return ret;
}
</pre>
<p>Now calling <tt>inGroupsOf(3)</tt> on any Array would return that same array split into as many parts as needed to ensure no group has more than three items in it.</p>
<p>There are a number of objects you can extend, but the ones you will use the most are <tt>String</tt>, <tt>Array</tt>, <tt>Object</tt>, <tt>Number</tt>, <tt>Date</tt>. One trouble area you might face is calling methods on numbers. The following example will fail:</p>
<pre class="brush: jscript;">
Number.prototype.to_s = function(){
  return this + &quot;&quot;;
}

25.to_s();
</pre>
<p>The prototype function is correct, but the way we called it is wrong. There are two ways to call our custom functions on numbers:</p>
<pre class="brush: jscript;">
var n = 25;
n.to_s(); // Returns &quot;25&quot;

(25).to_s(); // Also returns &quot;25&quot;
</pre>
<h2>Think Start, Not End</h2>
<p>Its important when deciding what object to extend that you focus on what object type you are starting with, not so much which type you plan on ending with. For instance, if you wanted to extend an object to easily parse Twitter date strings you would not extend the <tt>Date</tt> object. You would extend the <tt>String</tt> object, and your function would return a <tt>Date</tt> object.</p>
<h2>Load Your Extensions First</h2>
<p>It is normally a good idea to load these extensions prior to any other library, including jQuery. Anytime you extend the prototype object, the new method is instantly available to all objects of the same type or any object that has inherited from that type. However, since you want to be sure your methods are always available, you guarantee their availability by loading them first.</p>
<h2>How to Group The Extensions</h2>
<p>Naming your files <tt>Prototype.Date.js</tt> and <tt>Prototype.Array.js</tt> is an easy way to keep all your extensions in one part of your JS folder, and easy to access during development. If you follow this method, you would simply put Date.prototype methods in the <tt>Prototype.Date.js</tt> file, etc. This starts to break down when you have parallel functions. You might have a <tt>toDateFromTwitter()</tt> method on the String object and a <tt>toTwitterFromDate()</tt> method on the Date object. Putting these in separate files might not make sense. At that point, you should put both these extensions in a file named TwitterHelpers.js or something similar. Obviously use what makes sense to you and works with your flow.</p>
<h2>Don&#8217;t Bloat</h2>
<p>Just because you write 500+ awesome Array extensions in the next 2 years, does not mean you need to include them on every project. Be sure to only use this technique when it makes sense for the project and when it helps clean up your code.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/javascript-can-learn-now-teach-it-tricks/">JavaScript Can Learn: Now Teach It Tricks!</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=VnRa1eOpj1w:8WCEBoZQh7M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=VnRa1eOpj1w:8WCEBoZQh7M:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=VnRa1eOpj1w:8WCEBoZQh7M:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=VnRa1eOpj1w:8WCEBoZQh7M:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=VnRa1eOpj1w:8WCEBoZQh7M:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=VnRa1eOpj1w:8WCEBoZQh7M:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=VnRa1eOpj1w:8WCEBoZQh7M:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=VnRa1eOpj1w:8WCEBoZQh7M:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=VnRa1eOpj1w:8WCEBoZQh7M:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=VnRa1eOpj1w:8WCEBoZQh7M:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=VnRa1eOpj1w:8WCEBoZQh7M:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/VnRa1eOpj1w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/javascript-can-learn-now-teach-it-tricks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/javascript-can-learn-now-teach-it-tricks/</feedburner:origLink></item>
		<item>
		<title>Roll Your Own PHP Framework: Part III</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/GYsTuSdOD7A/</link>
		<comments>http://fuelyourcoding.com/roll-your-own-php-framework-part-iii/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 16:10:33 +0000</pubDate>
		<dc:creator>Wess Cope</dc:creator>
				<category><![CDATA[Concepts & Training]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=652</guid>
		<description><![CDATA[In Part I and Part II we looked at how to set up our file structure, how to get URL routing working and how to set up templating for our little framework. In this final part to the series, we are going to briefly look at database access.
Mini-series Overview

Part 1: URL Routing and Directory Setup
Part [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/roll-your-own-php-framework-part-iii/">Roll Your Own PHP Framework: Part III</a></p>
]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/">Part I</a> and <a href="http://fuelyourcoding.com/roll-your-own-php-framework-part-ii/">Part II</a> we looked at how to set up our file structure, how to get URL routing working and how to set up templating for our little framework. In this final part to the series, we are going to briefly look at database access.</p>
<p><strong>Mini-series Overview</strong></p>
<ul>
<li><a href="http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/">Part 1: URL Routing and Directory Setup</a></li>
<li><a href="http://fuelyourcoding.com/roll-your-own-php-framework-part-ii/">Part 2: Templating</a></li>
<li>Part 3: Database Interaction</li>
</ul>
<p>You can download all the files put together during this three part series here:</p>
<div class="post_buttons" style="margin-bottom: 20px"><a href="http://fuelyourcoding.com/files/peanut_framework.zip"><img class="size-full wp-image-24 alignnone" style="margin-left: 30px" src="http://fuelyourcoding.com/files/download-button.gif" alt="Download zipped archive" width="229" height="68" /></a></div>
<p>I&#8217;m not going into detail about how to create an ORM or ActiveRecord clone.  We are just going to write a simple helper class to setup our connection and query.  Also I&#8217;m going to assume you know how to create a database and table in the database.</p>
<p>I have created a database called &#8220;peanut&#8221; and created table:</p>
<pre class="brush: plain;">
users:
+----------+--------------+------+-----+---------+----------------+
| Field    | Type         | Null | Key | Default | Extra          |
+----------+--------------+------+-----+---------+----------------+
| id       | int(11)      | NO   | PRI | NULL    | auto_increment |
| username | varchar(255) | NO   |     | NULL    |                |
| password | varchar(255) | NO   |     | NULL    |                |
+----------+--------------+------+-----+---------+----------------+
</pre>
<p>In this example we are going to use Mysql and the php mysql_ methods.  So break open system/database.php and drop the following in:</p>
<pre class="brush: php;">
&lt;?php

// Here is where we are setting up a simple wrapper class around mysql
// functions just to make it a little more convenient.  Our models will
// simple extend our database class and simplify making queries just a bit.
class Database
{
	protected var $connection;
	// Every time you instantiate this class you are going to create
	// a new connection to the database.
	public function __construct()
	{
		// First we setup up a nice little connection to the database,
		// make sure you use your connection information.  If the
		// connection fails we just die with the error.
		$this-&gt;connection = mysql_pconnect(&quot;localhost&quot;, &quot;root&quot;, &quot;somepassword&quot;) or die(&quot;MySQL Error: &quot; . mysql_error());

		// And let's tell mysql which db we are going to use.
		mysql_select_db( &quot;peanut&quot;, $this-&gt;connection );
	}

	// This is just a helper function to help out against
	// possible sql injection attacks.
	public function escapeString($string)
	{
		// we call mysql's 'cleaning' function on strings
		// just to make sure we get a little safer item to query
		// with.
		return mysql_real_escape_string($string);
	}

	// Here we will query the database with the passed query string,
	// build up an array of objects and return them, simple enough.
	public function query($qry)
	{
		// Here we make our query and set the result to a $result variable
		$result = mysql_query($qry) or die(&quot;MySQL Error: &quot; . mysql_error());

		// Create a container array variable to hold all of our result objects.
		$resultObjects = array();

		// This might look weird, but all we are doing is saying,
		// While you are still getting results, please put the next
		// result into the next spot on my array.
		while($resultObjects[] = mysql_fetch_object($result));

		// Now we just return our array that has all our result objects in it
		return $resultObjects;
	}

	// Here we add a simplier method for handling INSERTs and UPDATEs since
	// they do not return a result set.
	public function execute($qry)
	{
		$exec = mysql_query($qry) or die(&quot;MySQL Error: &quot; . mysql_error());
		return $exec;
	}
}
?&gt;
</pre>
<p>So we have our database class in place and ready to use, now we just need to require it in the index.php like we did the others, so pop that bad boy open and after the template require, do one just like it but for the database.php</p>
<p>Now let&#8217;s crack open actions/helloworld/models.php and let&#8217;s write a simple addUser and getAllUsers method to it.  We are going to make our model a class as well so that it  can extend our Database class that we wrote.</p>
<p>Here are the guts:</p>
<pre class="brush: php;">
&lt;?php

// All of our database back-and-forth will be handled in our models file
// Don't be mistaken, this is no where close to an ORM (Object Relational Mapper)
// it's just simplified database access.

class myModel extends Database
{
	// When our model is instantiated we just need
	// to also instantiate our parent class (Database)
	// so it knows to make the connection to the database.
	public function __construct()
	{
		// We just call the __construct of Database class.
		parent::__construct();
	}

	// addUser will use the execute method of Database
	// since we are inserting a value and not expecting
	// anything in return.
	public function addUser($username, $password)
	{
		// Here we use that little cleaning method we
		// wrote to make our strings pretty and make sure
		// they will play nice with mysql
		$username = $this-&gt;escapeString($username);
		$password = $this-&gt;escapeString($password);

		// We execute our insert and if it worked $success
		// will be true else it will be false.
		$success = $this-&gt;execute(&quot;INSERT INTO users (username, password) VALUES ('{$username}','{$password}')&quot;);

		// We return $success to inform our page action that it has or hasn't worked.
		return $success;
	}

	// This method does just what you think it would.
	// We are going to use the query function because
	// we are expecting data back, then we are just
	// going to return the array of user objects.
	public function getAllUsers()
	{
		// Populate the $users variable with the results of our query
		$users = $this-&gt;query(&quot;SELECT * FROM users&quot;);

		// Now we return our results
		return $users;
	}
}
?&gt;
</pre>
<p>Now we need to change our actions/helloworld/actions.php mypage page action to:</p>
<pre class="brush: php;">
&lt;?php
// We need to include our models file so we can access the database
require(PEANUT_ROOT_DIR . 'actions/helloworld/models.php');

// We simply define the function (the second item in our request url)
// making sure it is the same name as the one in the url.

function mypage()
{
	// Let's do some database work!
	// Here we are going to instantiate our model
	$model = new myModel();

	// Now let's add a user
	// On a funny note, if you keep refreshing it will add this
	// user over and over in your users table so your getAllUsers call
	// will result in a list that grows by one each time.
	$model-&gt;addUser(&quot;wess&quot;, &quot;password&quot;);

	// Now let's fetch all of our users and put them in our users
	// variable.
	$users = $model-&gt;getAllUsers();

	// Let's create a new template object and pass it the path to our template
	$template = new Template(&quot;helloworld/templates/helloworld.php&quot;);

	// I bet you want to display a table in your template with all your newly
	// created users. So let's do it

	// That's write we use the same set command, and it will set our array of users
	// to our template variable $users, and since php is our template language
	// it's real easy to print them to the screen.
	$template-&gt;set('users', $users);

	// Set our page variable &quot;title&quot; with the value &quot;Hello World&quot;
	$template-&gt;set('title', 'Hello World');

	// Set our page variable &quot;message&quot; with our little message
	$template-&gt;set('message','This is my first message for my template');

	// Now we can call render and return it to dispatch to
	// display in our browser
	return $template-&gt;render();
}
?&gt;
</pre>
<p>So now you are handing all your users from your database to the template, so let&#8217;s display them. Change your <tt>actions/helloworld/templates/helloworld.php</tt> file to:</p>
<pre class="brush: xml;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;meta http-equiv=&quot;Content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
		&lt;title&gt;My PEANUT Page&lt;/title&gt;

	&lt;/head&gt;
	&lt;body&gt;
		&lt;h1&gt;&lt;?php echo $title ?&gt;&lt;/h1&gt;
		&lt;p&gt;&lt;?php echo $message ?&gt;&lt;/p&gt;

		&lt;h2&gt;Users:&lt;/h2&gt;
		&lt;table&gt;
			&lt;thead&gt;
				&lt;tr&gt;
					&lt;th&gt;ID&lt;/th&gt;
					&lt;th&gt;Username&lt;/th&gt;
					&lt;th&gt;Password&lt;/th&gt;
				&lt;/tr&gt;
			&lt;/thead&gt;
			&lt;tbody&gt;
				&lt;!--
					Here we are going to use native php foreach look
					to create each row of the table with our list of users.
					Notice how the foreach is done with a : and surrounding php tags.
				--&gt;
				&lt;?php foreach($users as $user): ?&gt;
					&lt;tr&gt;
						&lt;td&gt;&lt;?php echo $user-&gt;id ?&gt;&lt;/td&gt;
						&lt;td&gt;&lt;?php echo $user-&gt;username ?&gt;&lt;/td&gt;
						&lt;td&gt;&lt;?php echo $user-&gt;password ?&gt;&lt;/td&gt;
					&lt;/tr&gt;
				&lt;?php endforeach; ?&gt;
			&lt;/tbody&gt;
		&lt;/table&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Now if all went well, you should save all your files and open up: <a href="http://mywebapp.local/helloworld/mypage">http://mywebapp.local/helloworld/mypage</a> and see all the users that you added in a table.</p>
<p>So you have created a template class, url basic url routing, simplified database access, and a page action.  You have all the core basics of a PHP Framework at your hands now.  This is just for a starting point or foundation of understanding, please do not use this in a production environment.</p>
<p>I have really enjoyed writing this and I hope you learned something from my rambling!  The source code is available for download at the top of this article.</p>
<p>Take care,<br />
Wess &#8220;Wattz&#8221;</p>
<p><strong>Updated October 26, 2009: Thanks to Alex and Ian for spotting some errors in the code and supplying the fixes. The code examples have been updated to reflect the changes as has the ZIP file.</strong></p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/roll-your-own-php-framework-part-iii/">Roll Your Own PHP Framework: Part III</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=GYsTuSdOD7A:rpHdFqLBjmQ:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=GYsTuSdOD7A:rpHdFqLBjmQ:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=GYsTuSdOD7A:rpHdFqLBjmQ:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=GYsTuSdOD7A:rpHdFqLBjmQ:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=GYsTuSdOD7A:rpHdFqLBjmQ:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=GYsTuSdOD7A:rpHdFqLBjmQ:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=GYsTuSdOD7A:rpHdFqLBjmQ:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=GYsTuSdOD7A:rpHdFqLBjmQ:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=GYsTuSdOD7A:rpHdFqLBjmQ:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=GYsTuSdOD7A:rpHdFqLBjmQ:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=GYsTuSdOD7A:rpHdFqLBjmQ:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/GYsTuSdOD7A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/roll-your-own-php-framework-part-iii/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/roll-your-own-php-framework-part-iii/</feedburner:origLink></item>
		<item>
		<title>Easy to update thumbnail gallery using Textpattern and Galleriffic</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/3-lbBTcv6hw/</link>
		<comments>http://fuelyourcoding.com/easy-to-update-thumbnail-gallery-using-textpattern-and-galleriffic/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 16:22:10 +0000</pubDate>
		<dc:creator>Marie Poulin</dc:creator>
				<category><![CDATA[Concepts & Training]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[Textpattern]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=631</guid>
		<description><![CDATA[This tutorial assumes that you have a fairly strong understanding of HTML and CSS. I have provided a basic style sheet with all necessary styles to achieve the look of gallery demo, but please feel free to edit the css. We will be building a very simple updateable thumbnail gallery using Textpattern and Galleriffic. There [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/easy-to-update-thumbnail-gallery-using-textpattern-and-galleriffic/">Easy to update thumbnail gallery using Textpattern and Galleriffic</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This tutorial assumes that you have a fairly strong understanding of HTML and CSS. I have provided a basic style sheet with all necessary styles to achieve the look of gallery demo, but please feel free to edit the css. We will be building a very simple updateable thumbnail gallery using <strong>Textpattern</strong> and <strong>Galleriffic</strong>. There are a few <a title="galleriffic txptips" href="http://txptips.com/galleriffic-image-gallery">tutorials</a> out there of a similar nature, but I have found this to be the simplest way to integrate Galleriffic with Textpattern.</p>
<div class="post_buttons"><a href="http://fuelyourcoding.com/files/tp_gallery.zip"><img class="size-full wp-image-24 alignnone" style="margin-left: 30px" src="http://fuelyourcoding.com/files/download-button.gif" alt="Download zipped archive" width="229" height="68" /></a></div>
<p>Below is a screen capture of the final gallery. To see the gallery in action, click <a title="Thumbnail Gallery" href="http://www.textpatternworkshops.com/gallery" target="_blank">here</a></p>
<p><img class="alignnone size-full wp-image-634" title="thumbnail gallery" src="http://fuelyourcoding.com/files/sample.jpg" alt="thumbnail gallery" width="606" height="350" /></p>
<p>This tutorial assumes that you have textpattern installed and ready to go.<br />
( Download the latest version of Textpattern here: <a title="textpattern download" href="http://textpattern.com/download" target="_blank">http://textpattern.com/download</a>)</p>
<h2>Galleriffic</h2>
<p>This gallery is based on Galleriffic, a jQuery plugin for rendering fast-performing photo galleries. This is adapted from <a title="galleriffic" href="http://www.twospy.com/galleriffic/" target="_blank">http://www.twospy.com/galleriffic/</a> to work with textpattern so you (and your clients!) can easily update the gallery. In a nutshell, the gallery works by associating image id #s with a specific article. The article form <strong>gallery</strong> and <strong>article_image_form</strong> work together to render the article in the form of all of the associated images (in their thumbnail format) to appear as an unordered list on the left, while the full version of the current image appears on the right. All that is necessary to add or change images, is to change the numbered list appearing in the advanced options on the left of the article containing the images. So easy once implemented, even a client that doesn&#8217;t speak nerd can add, subtract or change their own images.</p>
<h2>Upload the files</h2>
<p>Upload both of the galleriffic files included in the <strong>files</strong> folder of the download, by uploading them through the <strong>Content</strong> &gt; <strong>Files</strong> tab. I modified the jquery.galleriffic.js file so that the pagination does not appear above the thumbnails. Should you wish to further customize the gallery, I do suggest checking out the original <a title="galleriffic" href="http://www.twospy.com/galleriffic/" target="_blank">Galleriffic demo</a>.</p>
<h2>Install the relevant plugins</h2>
<p>Install the following plugins (these are included in the <strong>Plugins</strong> folder in the download):</p>
<ul>
<li> upm_image by Mary Fredbord – more powerful image display</li>
<li> ebl-image-edit by Eric Limegrover – introduces advanced image editing functionality</li>
</ul>
<p>(I have had technical issues with v.2 of this plugin, so I continue to use v1. Both are included in the plugin folder.)</p>
<p><strong>ebl-image-edit</strong> is great for sizing/creating thumbnails on the fly, without having Textpattern automatically centre the thumbnail. It is not essential to this tutorial, but it&#8217;s very very handy!</p>
<p><img class="alignnone size-full wp-image-635" title="thumbnailplugin" src="http://fuelyourcoding.com/files/thumbnailplugin.jpg" alt="thumbnailplugin" width="606" height="432" /></p>
<h2>Set up your forms</h2>
<p>You can find these forms in the <strong>forms</strong> folder in the download.</p>
<h3>gallery</h3>
<p>Create a new form called &#8220;gallery&#8221; and choose &#8220;article&#8221; for the type:</p>
<pre class="brush: xml;">

&lt;txp:upm_article_image form=&quot;article_image_form&quot; wraptag=&quot;ul&quot;
class=&quot;thumbs noscript&quot; /&gt;
</pre>
<h3>article_image_form</h3>
<p>Create a new form called &#8220;article_image_form&#8221; and choose &#8220;misc&#8221; for the type:</p>
<pre class="brush: xml;">

&lt;li&gt;&lt;a href=&quot;&lt;txp:upm_img_full_url /&gt;&quot; title=&quot;&lt;txp:upm_img_caption /&gt;&quot; class=&quot;thumb&quot;&gt;&lt;img src=&quot;&lt;txp:upm_img_thumb_url /&gt;&quot; alt=&quot;&lt;txp:upm_img_alt /&gt;&quot; /&gt;&lt;/a&gt;

&lt;div&gt;
&lt;div&gt;&lt;txp:upm_img_alt /&gt; &lt;/div&gt;
&lt;div&gt;&lt;txp:upm_img_caption /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
</pre>
<p>If you don&#8217;t want captions, delete the whole caption div.</p>
<p>Basically we have taken this code from galleriffic:</p>
<pre class="brush: xml;">

&lt;ul&gt; &lt;li&gt; &lt;a href=&quot;path/to/slide&quot; title=&quot;your image title&quot;&gt; &lt;img src=&quot;path/to/thumbnail&quot; alt=&quot;your image title again for graceful degradation&quot; /&gt; &lt;/a&gt; &lt;div&gt; (Any html can go here) &lt;/div&gt; &lt;/li&gt; ... (repeat for every image in the gallery) &lt;/ul&gt;
</pre>
<p>and modified it so the article forms generate this code from the image numbers that we will associate with the gallery article. We&#8217;re basically saying, &#8220;take the images associated with this article, put the thumbnail versions of those images on the left with these classes and this formatting, and put the full version of the selected image on the right.&#8221; Huh? Just follow along, I promise it will all make sense soon&#8230;</p>
<h2>Set up your page</h2>
<p>In the <strong>pages</strong> folder I have included a template for this gallery page (gallery.html). Create a new page template in textpattern: <strong>Presentation</strong> &gt; <strong>Pages</strong>. At the bottom, &#8220;copy page as&#8221;, name it <strong>gallery</strong>, and click &#8220;copy.&#8221; Make sure whatever section you are using for the gallery is in fact using the <strong>gallery</strong> page as its template. At the bottom of the page you will notice the galleriffic script. This is where you can make adjustments to sizes, number of thumbnails, etc. In this example I have set a limit of 9 to the thumbnails. At the bottom of the page, near the top of the script, it looks like:</p>
<pre class="brush: xml;">

numThumbs: 9,
</pre>
<h2>Set up your style</h2>
<p>I have created a master style sheet that incorporates some of the Textpattern defaults as well as galleriffic specific css. Copy the content from the <strong>screen.css</strong> file provided in the Styles folder and paste it into your default styles tab under <strong>Presentation</strong> &gt; <strong>Style</strong>.</p>
<h2>Add your images</h2>
<p>Go ahead and start uploading some images, and create some thumbnails. Make sure your images are all using the same size of thumbnail. Take note of the image ID numbers, as that is what you will use to call your images into the article. Make sure to add the <strong>Alt text</strong> and <strong>Caption </strong>when you upload, as this is what will appear to the left of the main image (unless you opted to delete the captions).<br />
<img class="alignnone size-full wp-image-639" title="caption" src="http://fuelyourcoding.com/files/caption.jpg" alt="caption" width="549" height="390" /></p>
<p>Create a new article called <strong>gallery</strong>. On the left hand side, click <strong>advanced options</strong>, and enter the ID numbers of the images you want to appear in the gallery, separated by commas. Make sure you post the article to the <strong>gallery</strong> section, or whichever section you have set up to display the gallery, and click publish. Your article should look something like this:</p>
<p><img class="alignnone size-full wp-image-638" title="article_image" src="http://fuelyourcoding.com/files/article_image.jpg" alt="article_image" width="606" height="415" /></p>
<p><strong>View Site.</strong> You should notice that the images have been automatically formatted into thumbnails on the left, with the first one appearing in full on the right. That&#8217;s it! You have a galleriffic gallery integrated with Textpattern. Play around with the html, settings, scripts and CSS to customize it to suit your own needs.</p>
<p>If you have any questions, suggestions, or requests for future articles, please do not hesitate to leave a comment.</p>
<p>Thanks, and happy coding!</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/easy-to-update-thumbnail-gallery-using-textpattern-and-galleriffic/">Easy to update thumbnail gallery using Textpattern and Galleriffic</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=3-lbBTcv6hw:LRd2apJ9Icc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=3-lbBTcv6hw:LRd2apJ9Icc:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=3-lbBTcv6hw:LRd2apJ9Icc:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=3-lbBTcv6hw:LRd2apJ9Icc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=3-lbBTcv6hw:LRd2apJ9Icc:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=3-lbBTcv6hw:LRd2apJ9Icc:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=3-lbBTcv6hw:LRd2apJ9Icc:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=3-lbBTcv6hw:LRd2apJ9Icc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=3-lbBTcv6hw:LRd2apJ9Icc:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=3-lbBTcv6hw:LRd2apJ9Icc:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=3-lbBTcv6hw:LRd2apJ9Icc:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/3-lbBTcv6hw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/easy-to-update-thumbnail-gallery-using-textpattern-and-galleriffic/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/easy-to-update-thumbnail-gallery-using-textpattern-and-galleriffic/</feedburner:origLink></item>
		<item>
		<title>Roll Your Own PHP Framework: Part II</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/5aU062egfSQ/</link>
		<comments>http://fuelyourcoding.com/roll-your-own-php-framework-part-ii/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 13:03:35 +0000</pubDate>
		<dc:creator>Wess Cope</dc:creator>
				<category><![CDATA[Concepts & Training]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[training]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=623</guid>
		<description><![CDATA[A little over a week ago, we looked at how to set up our file structure and how to get URL routing working in our little framework. So we now have something to handle urls and display a page, but we want to make the page a little more attractive. Since there is nothing fun [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/roll-your-own-php-framework-part-ii/">Roll Your Own PHP Framework: Part II</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/">A little over a week ago</a>, we looked at how to set up our file structure and how to get URL routing working in our little framework. So we now have something to handle urls and display a page, but we want to make the page a little more attractive. Since there is nothing fun about making php print html, let&#8217;s add a template piece to the puzzle. We won&#8217;t have to do too much since php is a great template language by itself. </p>
<p><strong>Mini-series Overview</strong></p>
<ul>
<li><a href="http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/">Part 1: URL Routing and Directory Setup</a></li>
<li>Part 2: Templating</li>
<li>Part 3: Database Interaction</li>
</ul>
<p><em>Note: I&#8217;m assuming you have a little OOP (Object Oriented Programming) experience.  There are a ton of tutorials out there, so just a heads up:  I won&#8217;t be teaching/explaining OOP here.</em></p>
<p>We are going to create a class <tt>Template</tt> and add a little code to it so it will return our pretty new page to our browser.</p>
<p>Wipe out <tt>system/template.php</tt> and add the following code to it:</p>
<pre class="brush: php;">
&lt;?php
// We are creating a simple class here to handle our templating.
// All this class will do is set some variables and return
// a rendered webpage using native php as the template language.
class Template
{
	// We setup $pageVars to hold all our pages
	// variables.
	private $pageVars = array();

	// We setup $template to define what file is our
	// template and were to get it.
	private $template;

	// When a new Template object is instantiated we want to make sure
	// we pass it a shortened path to the file we want it to use
	// as our template.
	// example: $template = new Template(&quot;helloworld/templates/helloworld.php&quot;);

	public function __construct($template)
	{

		// We setup our action directory
		$actionsDirectory = PEANUT_ROOT_DIR . 'actions';

		// Let's build and set our class var $template to the
		// value of $template that was passed into our __construct method
		$this-&gt;template = $actionsDirectory . '/' . $template;
	}

	// Now we create out set method to allow use to set variables that
	// we want in the template.
	// So in our page action we would do:
	// $template-&gt;set(&quot;title&quot;, &quot;hello world&quot;);
	// and in our template:
	// &lt;h1&gt;&lt;?php echo $title; ?&gt;&lt;/h1&gt;
	public function set($var, $val)
	{
		// This may look weird, but it's not to bad;
		// what we are doing is setting the index name
		// of our associative array pageVars
		// (we setup earlier at the top of the class)
		// to the value that we pass. so $pageVars[&quot;yourVar&quot;] = &quot;yourValue&quot;
		// is basically what it's doing.
		$this-&gt;pageVars[$var] = $val;
	}

	// To render we will need to do a couple of things.
	// First we will need to extract those pageVars then
	// include the template, populate the values in the template
	// and return a rendered page to the browser
	//
	// This is far more easy than you think it is
	// trust me!
	public function render()
	{
		// The extract function is a weird bird
		// when you call it on an associative array
		// it creates regular vars.
		// For instance:
		// 		$this-&gt;pageVars[&quot;yourVar&quot;]
		// becomes:
		// 		$yourVar
		// so basically we are converting all the
		// index keys (with their values), in pageVars to
		// their own respected variables
		extract($this-&gt;pageVars);

		// Now that we have all the variables extracted, the vars we set
		// in the template will be replaced by the value of the pageVars variables.
		// Now we start up our output buffer, grab our template and return the
		// buffer with it's &quot;rendered&quot; template
		ob_start();
			require($this-&gt;template);
		return ob_get_clean();
	}
}
</pre>
<p>Well hello templating! Now let&#8217;s do a couple of things to hook it up to our framework. First, let&#8217;s open up our <tt>www/index.php</tt> one more time and add the following line:</p>
<p>	require(PEANUT_ROOT_DIR . &#8217;system/template.php&#8217;);</p>
<p>Right underneath the <tt>dispatch.php</tt> require statement. Now let&#8217;s change our <tt>actions/helloworld/actions.php</tt> <tt>mypage</tt> function to look like:</p>
<pre class="brush: php;">
// We simply define the function (the second item in our request url)
// making sure it is the same name as the one in the url.
function mypage()
{
	// Let's create a new template object and pass it the path to our template
	$template = new Template(&quot;helloworld/templates/helloworld.php&quot;);

	// Set our page variable &quot;title&quot; with the value &quot;Hello World&quot;
	$template-&gt;set('title', 'Hello World');

	// Set our page variable &quot;message&quot; with our little message
	$template-&gt;set('message','This is my first message for my template');

	// Now we can call render and return it to dispatch to
	// display in our browser
	return $template-&gt;render();
}
</pre>
<p>Ok, so now our page action is setup to use our new found template class, now we need to setup our template</p>
<p>So inside actions/helloworld/templates/helloworld.php template put the following:</p>
<pre class="brush: xml;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;meta http-equiv=&quot;Content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
		&lt;title&gt;My PEANUT Page&lt;/title&gt;

	&lt;/head&gt;
	&lt;body&gt;
		&lt;!--
		See how we use native php here?
		echo out a variable, this is the same
		variable name that you use in your template
		set method ($template-&gt;('title', &quot;hello&quot;)).
		--&gt;
		&lt;h1&gt;&lt;?php echo $title ?&gt;&lt;/h1&gt;
		&lt;p&gt;&lt;?php echo $message ?&gt;&lt;/p&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Ok, so let&#8217;s see where we are at.  We have basic url routing, templating, and page actions.  We are only missing one thing, a way to talk to the database! That will be the next and final article in our mini-series on rolling your own PHP Framework.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/roll-your-own-php-framework-part-ii/">Roll Your Own PHP Framework: Part II</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=5aU062egfSQ:o_Qfq9Zm_yU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=5aU062egfSQ:o_Qfq9Zm_yU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=5aU062egfSQ:o_Qfq9Zm_yU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=5aU062egfSQ:o_Qfq9Zm_yU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=5aU062egfSQ:o_Qfq9Zm_yU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=5aU062egfSQ:o_Qfq9Zm_yU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=5aU062egfSQ:o_Qfq9Zm_yU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=5aU062egfSQ:o_Qfq9Zm_yU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=5aU062egfSQ:o_Qfq9Zm_yU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=5aU062egfSQ:o_Qfq9Zm_yU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=5aU062egfSQ:o_Qfq9Zm_yU:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/5aU062egfSQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/roll-your-own-php-framework-part-ii/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/roll-your-own-php-framework-part-ii/</feedburner:origLink></item>
		<item>
		<title>Winners Announced: HTMLRockstars Launch + 4 will WIN a copy of Snow Leopard!</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/0J_Nu5gegO0/</link>
		<comments>http://fuelyourcoding.com/htmlrockstars-launch-4-will-win-a-copy-of-snow-leopard/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 15:00:56 +0000</pubDate>
		<dc:creator>Adelle Charles</dc:creator>
				<category><![CDATA[Contests]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[contest]]></category>
		<category><![CDATA[HTMLRockstars]]></category>
		<category><![CDATA[Site Launch]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=589</guid>
		<description><![CDATA[HTMLRockstars Launches Today
To help celebrate with our good friends at HTMLRockstars (formally known as CSSRockstars) we are giving away (4) copies of Snow Leopard.

HTMLRockstars provides PSD to HTML service in just 3 days, for only $149. They take your existing design and transform it into valid, high quality, hand-coded markup. They also offer templating/skinning of [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/htmlrockstars-launch-4-will-win-a-copy-of-snow-leopard/">Winners Announced: HTMLRockstars Launch + 4 will WIN a copy of Snow Leopard!</a></p>
]]></description>
			<content:encoded><![CDATA[<h2>HTMLRockstars Launches Today</h2>
<p>To help celebrate with our good friends at <a href="http://htmlrockstars.com" target="_blank">HTMLRockstars</a> (formally known as CSSRockstars) we are giving away (4) copies of Snow Leopard.</p>
<p><img class="aligncenter size-medium wp-image-595" src="http://fuelyourcoding.com/files/PSD-to-HTML-HTMLRockstars.com-You-Design-We-Code-600x435.png" alt="PSD to HTML - HTMLRockstars.com - You Design, We Code" width="600" height="435" /></p>
<p><a href="http://htmlrockstars.com" target="_blank">HTMLRockstars</a> provides <strong>PSD to HTML service in just 3 days, for only $149</strong>. They take your existing design and transform it into valid, high quality, hand-coded markup. They also offer templating/skinning of the hottest CMS, Shopping Carts, and Blogging platforms such as WordPress. With semantic markup, microformat inclusion, documented HTML / HTML, and a money back guarantee, HTMLRockstars offers one of the most feature complete packages available. <a href="http://twitter.com/htmlrockstars" target="_blank">You can also follow them on Twitter</a>.</p>
<p><strong>Enter for your chance to win Snow Leopard! You will have 2 chances to win 1 of 4 copies courtesy of <a href="http://htmlrockstars.com" target="_blank">HTMLRockstars</a>.</strong></p>
<p><strong><img class="alignleft size-thumbnail wp-image-4439" src="http://www.fuelyourcreativity.com/files/MC223-150x150.jpg" alt="MC223" width="150" height="150" /></strong></p>
<h3>Here&#8217;s how:</h3>
<ul>
<li>All you have to do is <strong>follow</strong> <a href="http://twitter.com/fuelyourcoding" target="_blank">Fuel Your Coding on twitter</a> &amp; <strong>Retweet this: </strong>(RT @HTMLRockstars Launch + 4 will WIN a copy of Snow Leopard! Enter to Win on @fuelyourcoding http://twurl.nl/2r5jnl #FUELCONTEST)</li>
<li>Then head over to <a href="http://fuelyourcreativity.com" target="_blank">Fuel Your Creativity</a> to enter for a second chance. <strong>*please note: </strong>directions differ on Fuel Your Creativity.</li>
<li>Contest will end on both sites, Sunday at 12 Midnight EST.</li>
</ul>
<p><img class="aligncenter size-full wp-image-4413" src="http://www.fuelyourcreativity.com/files/468-Copy.gif" alt="468 - Copy" width="468" height="60" /></p>
<h2>Twitter Winners Announced:</h2>
<ol>
<li><a href="http://twitter.com/brookeduckart" target="_blank">@brookeduckart</a></li>
<li><a href="http://twitter.com/madmanstudios" target="_blank">@madmanstudios</a></li>
</ol>
<p>*To get your copy, please DM me <a href="http://twitter.com/adellecharles" target="_blank">@adellecharles</a></p>
<p>Be sure to check out <a href="http://fuelyourcreativity.com" target="_blank">Fuel Your Creativity</a> if you didn&#8217;t win here!</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/htmlrockstars-launch-4-will-win-a-copy-of-snow-leopard/">Winners Announced: HTMLRockstars Launch + 4 will WIN a copy of Snow Leopard!</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=0J_Nu5gegO0:h-gDYGNeCKk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=0J_Nu5gegO0:h-gDYGNeCKk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=0J_Nu5gegO0:h-gDYGNeCKk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=0J_Nu5gegO0:h-gDYGNeCKk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=0J_Nu5gegO0:h-gDYGNeCKk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=0J_Nu5gegO0:h-gDYGNeCKk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=0J_Nu5gegO0:h-gDYGNeCKk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=0J_Nu5gegO0:h-gDYGNeCKk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=0J_Nu5gegO0:h-gDYGNeCKk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=0J_Nu5gegO0:h-gDYGNeCKk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=0J_Nu5gegO0:h-gDYGNeCKk:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/0J_Nu5gegO0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/htmlrockstars-launch-4-will-win-a-copy-of-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/htmlrockstars-launch-4-will-win-a-copy-of-snow-leopard/</feedburner:origLink></item>
		<item>
		<title>PHP Frameworks? Just roll your own! – PART 1</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/e7WJ1E7lsaU/</link>
		<comments>http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 12:13:01 +0000</pubDate>
		<dc:creator>Wess Cope</dc:creator>
				<category><![CDATA[Concepts & Training]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[concept]]></category>
		<category><![CDATA[directory]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[url]]></category>
		<category><![CDATA[url routing]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=601</guid>
		<description><![CDATA[There are quite a few php frameworks out there.  Some huge, some small; Some useful, some not.  I often hear developers, even myself, complain about frameworks in php not having or not doing something the way they/we want it too.  So my solution? Roll your own framework! This series of articles is [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/">PHP Frameworks? Just roll your own! &#8211; PART 1</a></p>
]]></description>
			<content:encoded><![CDATA[<p>There are quite a few php frameworks out there.  Some huge, some small; Some useful, some not.  I often hear developers, even myself, complain about frameworks in php not having or not doing something the way they/we want it too.  So my solution? Roll your own framework! This series of articles is going to give you a brief and quick intro on how to do just that.  We are going to cover url routing, basic database connection, basic templating and basic rewrite rules for Apache.  What we will not cover is ORM development, advanced routing and installation of LAMP (Linux, Apache, MySQL, PHP). Also error checking will be next to none as this is just an example.</p>
<p><strong>Mini-series Overview</strong></p>
<ul>
<li>Week 1: URL Routing and Directory Setup</li>
<li>Week 2: Templating</li>
<li>Week 3: Database Interaction</li>
</ul>
<p>To get started let&#8217;s setup our directory structure.  We are going to call our framework &#8220;Peanut&#8221; (first thing that popped in my head).<br />
So for our structure let&#8217;s make it really basic:</p>
<pre>
MyWebApp/
  '---actions/
    '---helloworld/
      '--- actions.php
      '--- models.php
      '--- templates/
        '--- yourTemplateHere.php
'---system/
  '--- template.php
  '--- database.php
  '--- dispatch.php
'---www/
  '--- js/
  '--- css/
  '--- images/
  '--- index.php
</pre>
<p>Let&#8217;s break this structure down, it&#8217;s simple.  </p>
<p>MyWebApp: the root of your web app that will be using our &#8220;Peanut&#8221; framework</p>
<ul>
<li>actions: this will contain all the pages our web app will use.
<ul>
<li>helloworld: is the name of our page action or &#8217;section&#8217; of our site
<ul>
<li>actions.php: is where we will code our page actions</li>
<li>models.php: where we will write all our database interaction</li>
<li>templates: this is the folder we will store all our views/templates</li>
</ul>
</li>
</ul>
</li>
<li>system: this is where we will store all our framework specific classes/source/libraries
<ul>
<li>template.php: This will handle all of our template rendering.</li>
<li>database.php: This is for our database connection and access</li>
<li>dispatch.php: This will parse our url and call the correct page action.</li>
</ul>
</li>
<li>www: this is our root web directory, it is also where we will pull everything together.
<ul>
<li>js: the directory where you store your javascript</li>
<li>css: put your style sheets in here</li>
<li>images: guess!</li>
<li>index.php: This is the file that will initiate and pull together the pieces of Peanut.</li>
</ul>
</li>
</ul>
<p>Now that we have a directory structure, let&#8217;s setup a virtual host in Apache to accommodate for Peanut. Here is an example of a virtual host you can use (here is what I do on my Mac):</p>
<pre class="brush: plain;">
NameVirtualHost *:80

&lt;VirtualHost *:80&gt;
        ServerName      mywebapp.local
        DocumentRoot    /Users/wcope/Sites/mywebapp/www

        AcceptPathInfo On

        RewriteEngine On
        RewriteRule     /*\.(css|js|gif|png|jpe?g)$ - [NC,L]
        RewriteRule &quot;^(.*)$&quot;    &quot;/index.php?_url=$1&quot; [QSA,L]

        &lt;Directory &quot;/Users/wcope/Sites/mywebapp/www&quot;&gt;
                AllowOverride All
                Order allow,deny
                Allow from all
        &lt;/Directory&gt;

&lt;/VirtualHost&gt;
</pre>
<p>And In my /etc/hosts file I add this line:</p>
<pre class="brush: plain;">
127.0.0.1	mywebapp.local
</pre>
<p>That will allow &#8216;mywebapp.local&#8217; to resolve to my localhost where Apache will pick it up and kick it off to the virtual host we created. Inside that virtual host we have some rewrite rules that will redirect all request made (except css, js, gif, png, jpeg/jpg) to index.php?_url=$1.  To break that down in the simplest way, basically Apache takes: mywebapp.local/some/page and redirects it to index.php?_url=/some/page (but you never see the latter). Also notice that we made the root directory of our virtual host to our www folder where index.php is.</p>
<p>Ok, so now we have our directory structure, virtual host and rewrite rules all setup.  If you have any detailed questions about Apache, mod_rewrite, virtual hosts, host files, etc. Sorry they will not be covered here due to the fact that there is tons on it out there&#8230; so hit up your local <a href="http://google.com"> google.com</a> :). </p>
<p>So now let&#8217;s get to some code.</p>
<p>So first lets write our dispatch code since that will be what is responsible for routing all our request to the proper pages.</p>
<p>Open up <tt>index.php</tt> in your favorite text editor and let&#8217;s slap some code in it:</p>
<p>In this file is a good place to put constant variables, include any files and call our dispatch (once we write it). But for right now let&#8217;s do a little test, and also write a little helper function I&#8217;m going to use to print stuff to the screen that can help us see what&#8217;s going on.</p>
<pre class="brush: php;">
&lt;?php
// First let's define our apps root directory
define(&quot;PEANUT_ROOT_DIR&quot;, realpath(dirname(__FILE__) . '/../') . '/');

// now a pretty little dump function (or if you have xdebug you can just use var_dump)
function dump($item, $die=true)
{
	$printString = '&lt;pre&gt;' . print_r($item, true) . '&lt;/pre&gt;';
	if($die)
		die($printString);
	else
		echo $printString;
}

// Now let's just dump our URL to make sure that all paths lead here
dump($_GET);
?&gt;
</pre>
<p>Now if we bring up our url: http://mywebapp.local/some/url/ we should see something like:</p>
<pre class="brush: php;">
Array
(
    [_url] =&gt; /some/url/
)
</pre>
<p>So now we can see that our rewrite is working and we are ready to start writing our dispatch function, so let&#8217;s change our index.php code a little.</p>
<pre class="brush: php;">
&lt;?php
// First let's define our apps root directory
define(&quot;PEANUT_ROOT_DIR&quot;, realpath(dirname(__FILE__) . '/../') . '/');

// now a pretty little dump function (or if you have xdebug you can just use var_dump)
function dump($item, $die=true)
{
	$printString = '&lt;pre&gt;' . print_r($item, true) . '&lt;/pre&gt;';
	if($die)
		die($printString);
	else
		echo $printString;
}

// Let's comment this out
// dump($_GET);
// and add this:

// first we are going to drop our dispatch file in here
require(PEANUT_ROOT_DIR . 'system/dispatch.php');

// then call our dispatch function to handle the url
// Notice Im not passing in $_GET or $_GET['_url'], being that
// $_GET is a global system variable, I don't have to worry about it
// here.

dispatch();
?&gt;
</pre>
<p>So now let&#8217;s save that and crack open our system/dispatch.php file and and add some code to it to handle our new found url pattern.  As I said before, this will only be a simple router with no config or predefined url pattern to page action mapping.</p>
<p>So, inside dispatch.php, let&#8217;s add:</p>
<pre class="brush: php;">
&lt;?php
// Here we are going to handle our url request

function dispatch()
{
	// First we are going to grab our url path and trim the / of the
	// left and the right
	$url = trim($_GET['_url'], '/');

	// Now we are going to split the url on the / which
	// will give us an array with 2 indexes.
	$url = explode('/', $url);

	// Let's just print out our array to get a visual of
	// what we are working with.
	dump($url);
}

?&gt;
</pre>
<p>Now if you refresh your browser at our current url (http://mywebapp.local/some/url/) you should see:</p>
<pre class="brush: php;">
Array
(
    [0] =&gt; some
    [1] =&gt; url
)
</pre>
<p>Great, now we have 2 clean items to work with.  So let&#8217;s tell dispatch that the item at index 0 will be our folder and item at 1 will be the page action inside our actions.php file.  Since our directory structure is setup to use <tt>actions/helloworld/actions.php</tt>, let&#8217;s setup dispatch to include the file with our action in it in the directory that was requested in the url.  So change dispatch.php to look like:</p>
<pre class="brush: php;">
// Let's handle that url
function dispatch()
{
	// First we are going to grab the url path and trim the / off
	// the left and the right.
	$url = trim($_GET['_url'], '/');

	// We changed this from before to make it easier to read and also so we can
	// work with easier variables.  using the list (http://php.net/list) function
	// will map the array indexes to the respected order of the var names inside
	// the list function call (better explanation at php.net/lists).
	list($directory, $action) = explode('/', $url);

	// Now we drop in our respected actions file from the directory in the url
	require(PEANUT_ROOT_DIR . 'actions/' . $directory . '/actions.php');

	// And call the action from inside our actions.php file
	// and since we want to end our request with the return value of our requested method
	// let's just die on the return.
	die($action());
}
</pre>
<p>Now we need to add our action inside our actions.php file, so open it up and drop the following<br />
in it:</p>
<pre class="brush: php;">
&lt;?php

// We simply define the function (the second item in our request url)
// making sure it is the same name as the one in the url.
function mypage()
{
	// For now we are simply going to return &quot;Hello World&quot; string
	return &quot;Hello World&quot;;
}

?&gt;
</pre>
<p>So let&#8217;s give this a shot.  Open up your web browser and point it to: http://mywebapp.local/helloworld/mypage.You should see a pretty little &#8220;Hello World&#8221; in the browser. If you do, congrats! You now have routing in your new Peanut framework.  </p>
<p>Next week we will see how to add templating into our framework.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/">PHP Frameworks? Just roll your own! &#8211; PART 1</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=e7WJ1E7lsaU:DDtvQ3J2G0g:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=e7WJ1E7lsaU:DDtvQ3J2G0g:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=e7WJ1E7lsaU:DDtvQ3J2G0g:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=e7WJ1E7lsaU:DDtvQ3J2G0g:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=e7WJ1E7lsaU:DDtvQ3J2G0g:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=e7WJ1E7lsaU:DDtvQ3J2G0g:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=e7WJ1E7lsaU:DDtvQ3J2G0g:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=e7WJ1E7lsaU:DDtvQ3J2G0g:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=e7WJ1E7lsaU:DDtvQ3J2G0g:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=e7WJ1E7lsaU:DDtvQ3J2G0g:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=e7WJ1E7lsaU:DDtvQ3J2G0g:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/e7WJ1E7lsaU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/</feedburner:origLink></item>
		<item>
		<title>Table of Contents jQuery Plugin</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/R-7yKHGF0f0/</link>
		<comments>http://fuelyourcoding.com/table-of-contents-jquery-plugin/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 17:35:12 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Freebies]]></category>
		<category><![CDATA[Plugins / Add-Ons]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[table of contents]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=578</guid>
		<description><![CDATA[This is just a short Friday post to announce a new jQuery plugin for you to use, fork and adapt for your projects! This plugin takes either a part of a web page, or the entire page, and builds a table of contents based on the H1 through H6 tags. Additionally, it can add &#8220;Top&#8221; links [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/table-of-contents-jquery-plugin/">Table of Contents jQuery Plugin</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This is just a short Friday post to announce a new jQuery plugin for you to use, <a href="http://github.com/dcneiner/TableOfContents/tree/master">fork</a> and adapt for your projects! This plugin takes either a part of a web page, or the entire page, and builds a table of contents based on the H1 through H6 tags. Additionally, it can <a href="/scripts/toc/examples/example2.html">add &#8220;Top&#8221; links to the headers</a>, be styled as nested &lt;ol&gt; or &lt;ul&gt; list, be styled as a straight list of links, and it even supports a <a href="/scripts/toc/examples/example3.html">proportionate spacing style </a>that matches the actual distance between the headers.</p>
<div class="post_buttons"><a href="http://fuelyourcoding.com/scripts/toc/jquery.toc.zip"><img class="size-full wp-image-24 alignnone" style="margin-left: 30px" src="http://fuelyourcoding.com/files/download-button.gif" alt="Download zipped archive" width="229" height="68" /></a><a href="http://fuelyourcoding.com/scripts/toc/"><img class="size-full wp-image-25 alignnone" style="margin-left: 30px" src="http://fuelyourcoding.com/files/example-button.gif" alt="View the example" width="229" height="68" /></a></p>
</div>
<p>All this was inspired yesterday by Janko&#8217;s article yesterday, &#8220;<a href="http://www.jankoatwarpspeed.com/post/2009/08/20/Table-of-contents-using-jQuery.aspx">Automatically generate table of contents using jQuery</a>.&#8221; Start by reading his article to get a background on the topic, then head over to the <a href="/scripts/toc/index.html">documentation page</a> for the download link as well as three different examples of usage.</p>
<p>This plugin is version 0.8, so please comment on any bugs you find. Feel free to <a href="http://github.com/dcneiner/TableOfContents/tree/master">follow or fork the project on github</a> as well! Keep in mind I didn&#8217;t spend ages getting the CSS on the example pages to be cross-browser ready, though the plugin itself has full cross-browser support.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/table-of-contents-jquery-plugin/">Table of Contents jQuery Plugin</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=R-7yKHGF0f0:HzPSbWFIj6I:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=R-7yKHGF0f0:HzPSbWFIj6I:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=R-7yKHGF0f0:HzPSbWFIj6I:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=R-7yKHGF0f0:HzPSbWFIj6I:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=R-7yKHGF0f0:HzPSbWFIj6I:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=R-7yKHGF0f0:HzPSbWFIj6I:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=R-7yKHGF0f0:HzPSbWFIj6I:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=R-7yKHGF0f0:HzPSbWFIj6I:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=R-7yKHGF0f0:HzPSbWFIj6I:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=R-7yKHGF0f0:HzPSbWFIj6I:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=R-7yKHGF0f0:HzPSbWFIj6I:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/R-7yKHGF0f0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/table-of-contents-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/table-of-contents-jquery-plugin/</feedburner:origLink></item>
		<item>
		<title>Create a Simple Portfolio Website and Blog with Textpattern</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/1ddHXpLcN8Y/</link>
		<comments>http://fuelyourcoding.com/create-a-simple-portfolio-website-and-blog-with-textpattern/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 11:05:43 +0000</pubDate>
		<dc:creator>Marie Poulin</dc:creator>
				<category><![CDATA[Languages]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[Textpattern]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=537</guid>
		<description><![CDATA[*** UPDATED: The original zip file was missing a few important files. Please re-download the zip file to get all the files referenced in this tutorial. ***
Why Textpattern?
Okay, I will be the first to admit that when I first started with Textpattern, I was in way over my head. I had never worked with a [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/create-a-simple-portfolio-website-and-blog-with-textpattern/">Create a Simple Portfolio Website and Blog with Textpattern</a></p>
]]></description>
			<content:encoded><![CDATA[<p><strong>*** UPDATED: The original zip file was missing a few important files. Please re-download the zip file to get all the files referenced in this tutorial. ***</strong></p>
<h2>Why Textpattern?</h2>
<p>Okay, I will be the first to admit that when I first started with Textpattern, I was in way over my head. I had never worked with a CMS before, and I wasn&#8217;t an expert with CSS. I had stumbled upon a beautiful portfolio website by another web designer, and I noticed in the footer that the website was built using Textpattern. I thought to myself, if this designer can build a dynamic portfolio website using Textpattern, surely I can too, right? So I made it my mission to learn and master Textpattern. I learned the hard way, since I didn&#8217;t know anyone who was familiar with it (Wordpress always seemed to be the CMS of choice). However, Textpattern has an enormously helpful community and many helpful articles, blogs, and forums where other users were generous enough to share their tips, tricks and plugins. Textpattern has now become my CMS of choice as I have found it to be undeniably powerful and flexible, and it doesn&#8217;t require any knowledge or experience with PHP (not to mention, it&#8217;s free and open source). Once you wrap your head around the basics, you can bend Textpattern to your will quite easily. Check out the publishing features on the <a href="http://textpattern.com/">textpattern website.</a></p>
<h2>Getting started</h2>
<p>This tutorial assumes that you have a fairly strong understanding of HTML and CSS, however I am using an adapted version of Google Blueprint CSS to keep things extra simple. We will be building a very simple portfolio website with a blog component. I will continue to add articles which will build on textpattern&#8217;s functionality, but for now I am stripping a lot of Textpattern&#8217;s defaults, which can be quite confusing if you&#8217;re not sure about the syntax.</p>
<p>Head over to the <a href="http://textpattern.com/download">textpattern website</a> to download the latest version. Follow the <a href="http://textbook.textpattern.net/wiki/index.php?title=Detailed_Installation_Instructions">detailed install instructions.</a></p>
<p>You will also need the files I provided in this zip file:</p>
<div class="post_buttons"><a href="http://fuelyourcoding.com/files/tp_portfolio_updated.zip"><img class="size-full wp-image-24 alignnone" style="margin-left: 30px" src="http://fuelyourcoding.com/files/download-button.gif" alt="Download zipped archive" width="229" height="68" /></a></div>
<p>Login to your site, and you should see something like this:</p>
<p><img class="alignnone size-medium wp-image-541" src="http://fuelyourcoding.com/files/txp_screencap1-600x263.jpg" alt="txp_screencap1" width="600" height="263" /></p>
<p>You will notice that Textpattern has 4 tabs at the top:<em> content, presentation, admin</em>, and <em>view site</em>. Go to your <em>admin</em> tab, and check your diagnostics to make sure that there are no errors in your installation. If all checks have passed, head over to your preferences, and change your <strong>site name</strong> and <strong>slogan</strong> (even if you choose for these not to appear as is, you should change them to be relevant to your own site). It is a matter of personal preference, but I like to change my <strong>permanent link mode</strong> to section/title, as I like the way it appears in my url. Since this is a beginner tutorial, I would recommend leaving the other settings as is until you are more comfortable with Textpattern.</p>
<p>In the Textpattern handbook, it is recommended that you code your site in HTML and CSS before building it on Textpattern. I tend to build my sites live within Textpattern because I find the textpattern tags and plugins can achieve what I want much faster than coding it by hand. It&#8217;s really a matter of personal preference.</p>
<p>What I am going to do is STRIP AWAY the Textpattern defaults, and simplify things a little bit. Once you get more comfortable with textpattern, you can begin to add in more functionality, but for the purposes of understanding how textpattern works, I think the defaults are a bit overkill when you&#8217;re learning.</p>
<h2>In a nutshell</h2>
<p>In a nutshell, textpattern works by posting <strong>articles</strong> (think of articles as your main content) to <strong>sections</strong> (main navigation) of your site. Each <strong>section</strong> is associated with a <strong>page</strong> template. The <strong>pages</strong> tab under <strong>Presentation</strong> is where you dictate the HTML structure of your page. This is where your html combines with <strong>txp</strong> tags to create the functionality of your templates. The <strong>style</strong> tab under <strong>presentation</strong> is where the css resides. Forms are the most powerful part of textpattern; they tell an article <strong>how</strong>, <strong>when</strong>, <strong>where</strong>, and <strong>why</strong> to appear! More details on forms below.</p>
<h2>Set up your sections</h2>
<p>Think of <strong>sections</strong> as the main navigation  of your site. In this example, we&#8217;ll use <strong>about</strong>, <strong>work</strong>, <strong>blog</strong> and <strong>contact</strong>. There is no need to create a &#8220;home&#8221; section, as the &#8220;default&#8221; section IS the home section, and you will notice that textpattern already has an <strong>about</strong> section by default. So create a work, blog, and contact section. I tend to leave the &#8220;articles&#8221; section that is there by default, and I use it to post my articles that appear only on the homepage but nowhere else. For the about and contact page, I tend to select NO for the setting: &#8220;on front page&#8221; , since the homepage can display articles from all sections, and I do not want my contact page to appear on my homepage.</p>
<h2>Install your plugins</h2>
<p>There are a number of plugins that are incredibly useful that I tend to install by default each time I create a new site. In the download files I have provided a <strong>plugin</strong> folder where you will find a number of txt files that contain the plugins you will need for this tutorial. Open the txt files one by one, and install the plugins by going to your Admin &gt; Plugins tab. Just copy and paste the text into the field, and hit upload. You will see a preview of the plugin. Scroll down and click Install. You will then see your plugin title, author, and description. By default, the plugins are NOT active until you click &#8220;no&#8221; under <em>active</em> to switch it to &#8220;yes.&#8221; Do this with all of the plugins provided in the plugins folder.</p>
<h2>Create your forms</h2>
<p>Forms work in one of two ways:</p>
<h3>1. As a reusable snippet of information.</h3>
<p>Your header, footer and navigation are likely to be the same on every page, so you would create this as a form, which you would then call into your page template.</p>
<p>An example of this type of form would be the <strong>header</strong> form, which you will find in the <strong>forms</strong> folder of the tutorial download. In your textpattern backend, go to Presentation &gt; Forms, and create a new form. Call it <strong>header</strong>, and choose &#8220;<strong>misc</strong>&#8221; for the type. Copy and paste the following code into the body of the form and save:</p>
<pre class="brush: xml;"> &lt;div id=&quot;head&quot;&gt;
&lt;h1&gt;&lt;txp:site_name /&gt;&lt;/h1&gt;
&lt;txp:section_list wraptag=&quot;ul&quot; break=&quot;li&quot; include_default=&quot;1&quot; default_title=&quot;home&quot; sections=&quot;, about, work, blog, contact&quot; active_class=&quot;active&quot;/&gt;
&lt;/div&gt; </pre>
<p>What this does it creates a div with an ID of <strong>head</strong>, uses your h1 tag to call your site name, and creates your main navigation. <strong>&lt;txp:section_list /&gt;</strong> creates a list of all the the site sections. What I have done is narrowed the selection down so it just calls the default section (while naming it &#8220;home&#8221;), the about section, work, blog and contact. It will wrap the entire list in a &#8220;ul&#8221;, and wrap each individual section with a &#8220;li&#8221;. It will also automatically add a class of &#8220;active&#8221; to the current section&#8217;s li. If you want more flexibility with your menu, you can always hard code it with HTML, however, this &lt;txp:section_list /&gt; tag is usually all you really need. By default, the section_list ul is assigned a class of .section_list.</p>
<h3>2. It tells an article how to behave</h3>
<p>One of the most important tags in your page template will be the &lt;txp:article /&gt; tag.</p>
<p>The following snippet:</p>
<pre class="brush: xml;">
&lt;txp:article form=&quot;single&quot; listform=&quot;default&quot; /&gt;
</pre>
<p>basically means: display the article using the <strong>form</strong> named &#8220;<strong>single&#8221;</strong> if you are on an<em> individual article page</em>, and using the <strong>form</strong> named &#8220;<strong>default&#8221;</strong> when you are <em>displaying a list of articles</em>.</p>
<p>In your Presentation &gt; Forms, the &#8220;<strong>single</strong>&#8221; form could look like this: (which would just display the title and the body of the article)</p>
<pre class="brush: xml;"> &lt;h3&gt;&lt;txp:title /&gt;&lt;/h3&gt;
&lt;txp:body /&gt; </pre>
<p>while the &#8220;default&#8221; form could look something like this: (which would display the title, and excerpt, with a link to the full version of the article)</p>
<pre class="brush: xml;"> &lt;h3&gt;&lt;txp:title /&gt;&lt;/h3&gt; &lt;txp:excerpt /&gt;
&lt;p&gt;&lt;a class=&quot;more&quot; href=&quot;&lt;txp:permlink /&gt;&quot;&gt;read more&lt;/a&gt;&lt;/p&gt; </pre>
<p>A list of the most basic and useful forms are provided to you in the forms folder in the download for this tutorial. Create all of them in the Presentation &gt; Forms. If you notice that some of the forms already exist, just override the textpattern defaults with the ones i&#8217;m providing. You should have the following forms (in brackets is the &#8220;type&#8221; you must select for the form):</p>
<ul>
<li>portfolio_listing (article)</li>
<li>portflio (article)</li>
<li>intro (article)</li>
<li>single (article)</li>
<li>subnav (article)</li>
<li>article_listing (article)</li>
<li>default (article)</li>
<li>head (misc)</li>
<li>foot (misc) &#8211; <em>make sure you add your own copyright info</em></li>
<li>meta (misc) &#8211; <em>make sure you add your own meta data in this form!</em></li>
<li>excerpt (article)</li>
<li>(article)</li>
</ul>
<h2>Set up your page templates</h2>
<p>I have created very simplified versions of the textpattern defaults, which you can build upon as you get more comfortable. In the Pages folder, you will find 3 files: default.html, archive.html and home.html. Override the textpattern defaults with the ones I am providing to you. Make sure you go back to your sections, and tell the default section to use page <strong>home</strong>, the blog page should use <strong>archive</strong>, and the rest should use <strong>default. </strong>You must hit save after each change, you cannot change multiple sections at once.</p>
<h2>Set up your style</h2>
<p>I have created a master style sheet based on Google Blueprint CSS and incorporates some of the Textpattern defaults. Copy the content from the <strong>screen.css</strong> file provided in the <strong>Styles</strong> folder and paste it into your default styles tab under Presentation &gt; Style.</p>
<h2>Add your portfolio</h2>
<p>I have created this portfolio with certain defaults, to help you get a feel for how textpattern works. Once you understand the basics, you should feel free to use your own image sizes, css, etc. As a basis, portfolio images should be sized to maximum width of 620px. Upload a few of your own images (i&#8217;ve included a few placeholder images) through the content &gt; images tab. Specify a size of 300px wide by 200px tall for your thumbnail. Click &#8220;crop&#8221; to avoid the image being squished to fit your dimensions. Hit save once you are finished. There are additional plugins which are fantastic for offering advanced image editing; if you are feeling adventurous, I highly recommend this plugin: ebl-image-edit, which will allow you greater flexibility for creating thumbnails and cropping, etc. Once you have uploaded an image, you will notice that Textpatern automatically assigns the image an id number. Take note of the id number, as that is how you will refer to your images in the future.</p>
<p>Head over to the Content &gt; Write tab to write your first article. Give it a title, put a description in the body. On the left, click &#8220;advanced options&#8221; and under <em>article image</em>, enter the id #&#8217;s (separated by a comma) of the images you wish to be associated with this article. Then, assign the article to the &#8220;work&#8221; section. When you are finished, hit &#8220;publish.&#8221; Continue to write your articles, assigning your images to each article. When you have written a few articles, you should click &#8220;view site&#8221; in the top right of the textpattern window. I tend to leave one tab with the textpattern backend open, with the live site in another, so I can easily refresh and see any changes (or errors!)</p>
<p>You should see something like this:</p>
<p><img class="size-medium wp-image-557 alignnone" src="http://fuelyourcoding.com/files/work_listing-600x495.jpg" alt="work_listing" width="600" height="495" /></p>
<p>This is basically the work page in its &#8220;listform.&#8221; If you click on any of the thumbnails or article titles, you will see the &#8220;individual article,&#8221; which should look something like this:</p>
<p><img class="alignnone size-medium wp-image-556" src="http://fuelyourcoding.com/files/work_individual-600x424.jpg" alt="work_individual" width="600" height="424" /></p>
<p>If you take a look at the code in the page template for work, you will notice this textpattern tag:</p>
<pre class="brush: xml;"> &lt;txp:article listform=&quot;portfolio_listing&quot; form=&quot;portfolio&quot; sort=&quot;posted desc&quot; limit=&quot;30&quot; /&gt; </pre>
<p>If we analyze the form portfolio_listing, it looks like this:</p>
<pre class="brush: xml;"> &lt;div class=&quot;span-8&quot;&gt;
&lt;txp:permlink&gt; &lt;txp:upm_article_image type=&quot;thumbnail&quot; limit=&quot;1&quot; class=&quot;border&quot;/&gt;   &lt;/txp:permlink&gt;
&lt;h3&gt;&lt;txp:permlink&gt;&lt;txp:title /&gt;&lt;/txp:permlink&gt;&lt;/h3&gt;
&lt;txp:excerpt /&gt;
&lt;/div&gt; </pre>
<p>This basically tells the page to list articles in the form of a div with a class of .span-8, which contains the &#8220;image associated with the article&#8221;, <em>in the form of a thumbnail</em>, limit it to 1 image, and link the image to the full version of the article. Underneath the image is the &#8220;title&#8221; of the article in the style of h3, which also links to the full version of the article. Beneath that, show the excerpt associated with that article.</p>
<p>If you take a look at the form &#8220;portfolio&#8221;, you should see this:</p>
<pre class="brush: xml;">&lt;div class=&quot;span-8&quot;&gt;
  &lt;h3&gt;&lt;txp:title /&gt;&lt;/h3&gt;
  &lt;txp:body /&gt;
&lt;/div&gt;
&lt;div class=&quot;span-16 last&quot;&gt;
   &lt;txp:upm_article_image /&gt;
&lt;/div&gt;  </pre>
<p>This basically creates a div with a class of .span-8 which contains the title and body of the article. Beside it floats a div with a class of .span-16 last, which contains the images associated with the article. Should you wish for the title to appear above the images on the right, you would simply move the &lt;h3&gt;&lt;txp:title /&gt;&lt;/h3&gt; over to the div with the class of .span-16. These forms basically determine the layout for your articles.</p>
<h2>A note about article and article_custom</h2>
<p>You will notice in the home.html template, that there are two different ways to call articles: &lt;txp:article /&gt; and &lt;txp:article_custom /&gt;. It took me a while to wrap my brain around the difference between the two, but here is how it works:</p>
<p>&lt;txp:article /&gt; will call your <strong>full article</strong> in whatever <strong>form</strong> you tell it to use. It is <strong>section-specific</strong>, which means it will automatically call an article from the section you are currently visiting. You must always have an article tag on your page.</p>
<p>&lt;txp:article_custom /&gt; Think of this as a LIST of your articles, in whatever form you tell it to use. Using this tag, you can call articles from ANY section into a page. For example, one the homepage, I am using the <strong>article_custom</strong> tag to display a snippet from the <strong>work</strong>, <strong>blog</strong>, and <strong>articles</strong> sections. In the archive template for example, on the left-hand side, I am using<strong> article_custom</strong> to display a full list of all articles posted to the blog page (in the form of <strong>subnav</strong>), and I am using the plugin &#8220;rvm_if_this_article&#8221; to automatically detect the current article and make it active.</p>
<h2>Create your <em>contact</em> page</h2>
<p>You can use the plugins provided (zem_contact_lang and zem_contact_reborn) to create a contact form on your contact page. If you have already installed the plugins provided, and wish to use the contact form, copy and paste the following details into the body of a new article.  To avoid formatting with textile, (textile will automatically render things in paragraphs) put a space before each line. Putting a space tells textpattern to format as is, with html, not textile.</p>
<pre class="brush: xml;">&lt;txp:zem_contact to=&quot;recipient@example.com&quot; label=&quot;&quot;&gt;
&lt;txp:zem_contact_text label=&quot;Name&quot; break=&quot;&quot;/&gt;
&lt;txp:zem_contact_email label=&quot;Email&quot; break=&quot;&quot;/&gt;
&lt;txp:zem_contact_textarea label=&quot;Message&quot; rows=&quot;10&quot; cols=&quot;23&quot; break=&quot;&quot;/&gt;
&lt;txp:zem_contact_submit label=&quot;Send&quot; /&gt;
&lt;/txp:zem_contact&gt; </pre>
<p>In the excerpt, paste any information you wish to be on the left hand side of the page, such as links to your facebook, twitter, or other profiles. And/or you could place an image here; it&#8217;s up to you. Assign the article to the &#8220;contact&#8221; page, and publish.</p>
<h2>Create your <em>about</em> page</h2>
<p>Create a new article for your about page. In the body write your bio. In the excerpt, place your photo (or other additional information you wish to provide). In order to call an image, you would write the following: &lt;txp:image id=&#8221;#&#8221; /&gt; and of course, replace the # with the proper image id number. Assign the article to the <strong>about</strong> section and publish. If you want to change how this page is displayed, you can edit the form named <strong>about</strong>.</p>
<h2>Create your <em>blog</em> page</h2>
<p>There are a million and one ways to organize your blog, and I am just demonstrating a very simplified way, since this is probably a whole other tutorial.</p>
<p>Write your blog article. Add an excerpt (usually the first paragraph of your blog). Publish it to your blog section. (You can feel free to create categories, and assign your article to categories, but I won&#8217;t get into how to navigate by category in this tutorial- stay tuned). When you click on the blog page, you should see a list of your articles in the form of a Title with an h3 style, followed by the articles&#8217; excerpt. You can click on the title to reach the full version of the article. You will notice a list of your blog articles on the left. I have limited the page to 10 articles on the listing page. When there are more than 10 articles, the page will display a link on the bottom that says &#8220;older&#8221; and &#8220;newer&#8221;. This page will always display the most recent articles first. Should you wish to change the order, you can change the timestamp of the article. Click on the article you wish to edit, and on the bottom right you will see a link that says &#8220;more.&#8221; Click that and you will notice that you can manually reset the timestamp. Hit save. Obviously, this is somewhat of a temporary solution for a blog, since having many blog postings would create quite a long list on the left. Stay tuned for an article on navigating your blog by category. If you wish for comments to be allowed, you must turn them &#8220;on&#8221; in the actual article itself. On the right hand side of the article page, you will see &#8220;allow comments.&#8221; Choose yes or no.</p>
<h2>Bring it all Home</h2>
<p><strong>Now it&#8217;s time to create your homepage.</strong></p>
<p>Create an article that will be an introductory paragraph on the homepage. We are using the form &#8220;intro&#8221; on this article, so it won&#8217;t display the title. If you want this article to use a title, change the form in the tag to &#8220;single&#8221; instead of &#8220;intro&#8221;. To clarify, you are looking for<strong> this tag</strong> in your home page template:</p>
<pre class="brush: xml;">&lt;txp:article_custom status=&quot;sticky&quot; sort=&quot;posted asc&quot; form=&quot;intro&quot;/&gt; </pre>
<p>Otherwise, use the heading of h3 in your body by typing h3. (with a space after the period) before your copy. (As opposed to wrapping your copy in &lt;h3&gt; tags) On the right, choose a status of &#8220;sticky&#8221;. We are making this article &#8220;sticky&#8221; because we don&#8217;t want it to be affected by newly written articles- it is more or less &#8220;static&#8221; content. Your work articles will always be displayed with the status of live, and the homepage will always display the most recent work.</p>
<p>You will notice in the &#8220;<strong>home</strong>&#8221; page template, that there is this tag: &lt;txp:image id=&#8221;3&#8243; /&gt;. Replace this number with the # of the image you want to appear here. The size is set to 940px wide by 350px high. Upload an image of that size through your images tab, and then replace the number in that tag with the appropriate id #.</p>
<p>Also on the homepage is a snippet from the most recent blog posting. If you want to change how the blog appears, you must edit the form &#8220;article_listing&#8221;. Keep in mind, this will change how your blogs appear on your blog page as well. If you wish for your blog to appear differently on the homepage than it does on the blog page, simple change the <strong>form</strong> used in this tag on your home template form:</p>
<pre class="brush: xml;"> &lt;txp:article_custom form=&quot;article_listing&quot; section=&quot;blog&quot; limit=&quot;1&quot; sort=&quot;posted desc&quot;/&gt; </pre>
<h2>Try it out!</h2>
<p>I&#8217;ve provided templates/forms/css to you to help simplify some of Textpattern&#8217;s funcionality, but its really up to you to make it work how you want it to. It is a very powerful CMS, and I would recommend looking through some of the <a href="http://textpattern.net/wiki/index.php?title=alphabetical_tag_listing">textpattern tags</a> to see what is available. There are many powerful &#8220;if&#8221; statements that provide even greater flexibility. Feel free to change any of the pages/forms/html and css I have provided to tailor it to your own needs. There are tons of resources out there to help you understand how to use it better. I highly recommend setting up a test site where you can play freely and experiment. There are so many different ways to work with textpatterns functionality; this is just the tip of the iceberg! If you think you might want to consider textpattern as your cms of choice, I recommend checking out the following sites:</p>
<ul>
<li><a href="http://www.txptips.com">http://www.txptips.com</a></li>
<li><a href="http://www.textpattern.com">http://www.textpattern.com</a></li>
<li><a href="http://www.welovetxp.com">http://www.welovetxp.com</a></li>
<li><a href="http://www.textpattern.org">http://www.textpattern.org</a></li>
</ul>
<p>Stay tuned for articles on how to build an extremely easy to update gallery page with thumbnail and captions, as well as category-based blog navigation, and easy nested sub-menus with automatically detected active class.</p>
<p>This is my first official &#8220;tutorial&#8221;, so if anything is unclear, feel free to post your comments/questions in the comments below, and I will do my best to answer any questions. I am also open to any feedback you may have as well, or suggestions for future articles.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/create-a-simple-portfolio-website-and-blog-with-textpattern/">Create a Simple Portfolio Website and Blog with Textpattern</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=1ddHXpLcN8Y:5LxC8wwM5bk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=1ddHXpLcN8Y:5LxC8wwM5bk:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=1ddHXpLcN8Y:5LxC8wwM5bk:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=1ddHXpLcN8Y:5LxC8wwM5bk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=1ddHXpLcN8Y:5LxC8wwM5bk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=1ddHXpLcN8Y:5LxC8wwM5bk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=1ddHXpLcN8Y:5LxC8wwM5bk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=1ddHXpLcN8Y:5LxC8wwM5bk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=1ddHXpLcN8Y:5LxC8wwM5bk:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=1ddHXpLcN8Y:5LxC8wwM5bk:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=1ddHXpLcN8Y:5LxC8wwM5bk:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/1ddHXpLcN8Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/create-a-simple-portfolio-website-and-blog-with-textpattern/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/create-a-simple-portfolio-website-and-blog-with-textpattern/</feedburner:origLink></item>
		<item>
		<title>Creating Your First Ruby on Rails Application From Scratch</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/vGJUoI8mwL4/</link>
		<comments>http://fuelyourcoding.com/creating-your-first-ruby-on-rails-application-from-scratch/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 16:14:31 +0000</pubDate>
		<dc:creator>Mageshcse</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=495</guid>
		<description><![CDATA[This tutorial which will help you create a basic Ruby on Rails application, without worrying too much about Ruby basics for now. Well, if you want to learn more about Ruby or Rails basic concepts, please refer the following links:

http://guides.rubyonrails.org/
http://www.rubyonrailstutorials.com/
http://railstutor.com/

And if you need more help, you can hit the #railsbridge channel of freenodeIRC.
So what are [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/creating-your-first-ruby-on-rails-application-from-scratch/">Creating Your First Ruby on Rails Application From Scratch</a></p>
]]></description>
			<content:encoded><![CDATA[<p>This tutorial which will help you create a basic Ruby on Rails application, without worrying too much about Ruby basics for now. Well, if you want to learn more about Ruby or Rails basic concepts, please refer the following links:</p>
<ul>
<li><a href="http://guides.rubyonrails.org/">http://guides.rubyonrails.org/</a></li>
<li><a href="http://www.rubyonrailstutorials.com/">http://www.rubyonrailstutorials.com/</a></li>
<li><a href="http://railstutor.com/">http://railstutor.com/</a></li>
</ul>
<p>And if you need more help, you can hit the #railsbridge channel of <a href="http://en.wikipedia.org/wiki/Freenode">freenode</a><a href="http://en.wikipedia.org/wiki/Internet_Relay_Chat">IRC</a>.</p>
<p>So what are you waiting for? Lets get started with creating our basic rails application!</p>
<h2>Getting Started</h2>
<p><strong>What is Ruby</strong></p>
<p><strong> </strong>Ruby is one of the easiest scripting languages I have ever seen; simple enough for non-tech people, powerful enough for advanced programmers and best of all, it doesn&#8217;t have a complex syntax or keywords to be memorized. Instead it is written in a simple English syntax.</p>
<p><strong>What is Rails</strong></p>
<p><strong> </strong>Rails is a web development framework written in the Ruby language, which has a general MVC (Models, Views, Controllers) type of structure to make everything simple for the developers. It allows you to write less code but accomplish more than most other languages/frameworks.</p>
<h2>Rails MVC Architecture</h2>
<p><img class="alignnone size-full wp-image-499" src="http://fuelyourcoding.com/files/image2.png" alt="image2" width="400" height="291" /></p>
<p>Rails has a MVC (Models, Views, Controllers) architecture and its benefits include:</p>
<li>Isolation of business logic from the user interface</li>
<li>Ease of keeping code DRY</li>
<li>Making it clear where different types of code belong for easier maintenance</li>
<p><em>From </em><a href="http://guides.rubyonrails.org/getting_started.html" target="_blank"><em>Getting Started With Rails</em></a></p>
<blockquote><p><strong>Models</strong></p>
<p><strong> </strong>A model represents the information (data) of the application and the rules to manipulate that data. In the case of Rails, models are primarily used for managing the rules of interaction with a corresponding database table. Most often, a single table in your database will correspond to a single model in your application. The bulk of your application&#8217;s business logic will be concentrated in the models.</p>
<p><strong>Views</strong></p>
<p><strong> </strong>Views represent the user interface of your application. In Rails, views are often HTML files with embedded Ruby code that performs tasks related solely to the presentation of the data. Views handle the job of providing data to the web browser or other tool that is used to make requests from your application.</p>
<p><strong>Controllers</strong></p>
<p><strong> </strong>Controllers provide the &#8220;glue&#8221; between models and views. In Rails, controllers are responsible for processing the incoming requests from the web browser, interrogating the models for data, and passing that data on to the views for presentation.<span style="color: #ff0000"><br />
</span></p></blockquote>
<h2>Welcome to Rails!</h2>
<p>Now lets create the sample &#8216;Slambook&#8217; Application.<span style="color: #ff0000"> </span></p>
<p><strong>Requirements:</strong></p>
<p><strong> </strong></p>
<li>Install <a href="http://ruby-lang.org">Ruby</a> and RubyGems</li>
<li>Install <a href="http://www.rubyonrails.org">Rails</a></li>
<li>Install SQLite, Postgres or MySQL</li>
<p>(Note: I will be using ubuntu (linux) and Postgres for building my rails application, but you can also install rails on your Windows or Mac machine as well.]</p>
<p>Once you have everything installed, we can start creating our rails application.  To begin, open a terminal (Console, Command Prompt, etc) and type the command:</p>
<pre class="brush: bash;"> rails slambook </pre>
<p>For this example we will use &#8217;slambook&#8217; as the name of the application which we will build. As soon as you hit enter, you will see the scripts flow in your terminal creating a bunch of files (as seen in the picture below):</p>
<p><img class="size-medium wp-image-500 alignnone" src="http://fuelyourcoding.com/files/image3-600x375.png" alt="image3" width="600" height="375" /></p>
<p>These are the files which rails automatically generates to create the framework for our application.</p>
<p>Now just change the directory to our application using:</p>
<pre class="brush: bash;"> cd guestbook </pre>
<p>and feel free to explore all the sub-directories and the files inside it to get an idea where the code lives.</p>
<p><img class="size-medium wp-image-501 alignnone" src="http://fuelyourcoding.com/files/image4-600x498.png" alt="image4" width="600" height="498" /></p>
<p>Now,  lets test if your rails application is working by using the command:</p>
<pre class="brush: bash;">script/server </pre>
<p>Open your favourite browser and type <a href="http://localhost:3000/">http://localhost:3000/</a> in the address bar and press Enter.</p>
<p><img class="alignnone size-medium wp-image-502" src="http://fuelyourcoding.com/files/image5-600x237.png" alt="image5" width="600" height="237" /></p>
<p><img class="alignnone size-medium wp-image-503" src="http://fuelyourcoding.com/files/image6-600x471.png" alt="image6" width="600" height="471" /></p>
<p>If you see a page similar to the above image, then your first rails application works fine (pat yourself on the back, you got it right)!</p>
<p>To start off, we are going to create the needed controller, model and views for our guestbooks post functionality which allows your friends to sign your &#8217;slambook&#8217;.</p>
<p>Using the command:</p>
<pre class="brush: bash;"> $script/generate scaffold post name:string address:text dob:date desire:text interests:text hobby:text signature:text </pre>
<p><img class="alignnone size-medium wp-image-504" src="http://fuelyourcoding.com/files/image7-600x300.png" alt="image7" width="600" height="300" /></p>
<p>Scaffold command creates a CRUD (Create, Read, Update, Delete) interface for your app ( a quick way of creating the MVC automatically). Alternatively, you can also create your controller, model and view manually using the command</p>
<pre class="brush: bash;"> $script/generate controller &lt;controller name&gt; // for creating controller and views </pre>
<pre class="brush: bash;"> $script/generate model &lt;model name&gt; // for creating model </pre>
<p>Here we are telling rails that we want code generated to handle a &#8220;Post&#8221; model, which has a string type for name and text for address, date for dob and so on. Notice this will generate some more files, one of which is the database migration file found inside the db/ directory</p>
<p><img class="alignnone size-medium wp-image-505" src="http://fuelyourcoding.com/files/image8-600x406.png" alt="image8" width="600" height="406" /></p>
<p>This is how our first migration file looks (slambook application):</p>
<p>The migration files are used for managing the CRUD (create, read, update and delete) activities of the database. If you haven&#8217;t created your database yet we can do it by a command:</p>
<pre class="brush: bash;"> $rake db:create </pre>
<p>Now you might wonder how rails connects our database, and for this purpose we provide our database information in the database.yml file which is found inside the config/ directory:</p>
<p><img class="alignnone size-full wp-image-506" src="http://fuelyourcoding.com/files/image9.png" alt="image9" width="507" height="199" /></p>
<p>This is how the database.yml file looks. We mention our database name and user details for rails to make the connection.</p>
<p>Since now we have recently created a new model for Post, a table must be created in our database and requires that we upgrade the database using this command:</p>
<pre class="brush: bash;"> $rake db:migrate // (instead of creating/updating the database table manually) </pre>
<p>This updates the database with the information from the migration file.</p>
<p>(Note: when this command is executed, the migration file inside the db/migrate/ directory say 20090718013114_create_posts.rb is used as an reference for updating the database)</p>
<p>Now lets checkout what we have done so far:</p>
<pre class="brush: bash;"> $script/server </pre>
<p>As before, open your browser and type <a href="http://localhost:3000/posts">http://localhost:3000/posts</a> in the address bar and press Enter to see your application:</p>
<p><img class="alignnone size-medium wp-image-507" src="http://fuelyourcoding.com/files/image10-600x270.png" alt="image10" width="600" height="270" /></p>
<p>If your page looks like that, then shout &#8220;Wow! I have created my first rails application!&#8221;</p>
<p>The page at <a href="http://localhost:3000/posts">http://localhost:3000/posts</a> shows the list of post made in your guestbook. Note there you have a link &#8220;New Post&#8221; which links to the the page at <a href="http://localhost/posts/new">http://localhost/posts/new</a> where your friends can sign your guestbook. You must wonder how these pages were created, so take a look at the app/views/posts directory which contains the html pages that were created by the scaffold command. These html pages have .html.erb extension which means ruby code can be embedded in your html files.</p>
<p>Now lets create a home page for our &#8217;slambook&#8217; application:</p>
<pre class="brush: bash;"> $script/generate controller home index </pre>
<p>This creates a controller &#8220;home&#8221; along with views in the app/view/home directory. Rails will create several files for you, including app/views/home/index.html.erb file. This is the template that we will use to display the results of the index action (method) in the home controller. Open this file in your text editor and edit it to contain the code that you want to display in your index page:</p>
<pre class="brush: ruby;"> &lt;h1&gt;Magesh's Slam-book or Guestbook&lt;/h1&gt; &lt;%= link_to &quot;View my book&quot;, posts_path %&gt; &lt;%= link_to &quot;Sign my book&quot;, new_post_path %&gt; </pre>
<p>The last two lines have added two links in my home page, one for people to view all the posts in my slambook and the other for new friends to use to sign my slambook.</p>
<p> tag is used to display the link. posts_path links to the posts/index page and new_post_path links to the posts/new page.</p>
<p>I suggest you also open the other .html.erb files in app/views/posts directory like index.html.erb, show.html.erb, edit.html.erb and new.html.erb to have a look around. Their functions are described in the file posts_controller.rb (controller) inside the app/controller directory.</p>
<p><img class="alignnone size-medium wp-image-508" src="http://fuelyourcoding.com/files/image11-600x427.png" alt="image11" width="600" height="427" /></p>
<p>Dont get confused with the above image, I will tell you how it works:</p>
<p>Lets take the index method first:</p>
<pre class="brush: ruby;">
def index @posts = Post.all respond_to do |format|
format.html # index.html.erb
format.xml { render :xml =&gt; @posts }
end
</pre>
<p>@posts variable stores all the posts and format.html is used to render the index.html.erb file in the app/views/posts directory.</p>
<p>Similarly the other methods such as new, edit and show are created. Notice that the methods inside the posts_controller.rb file are related to the files inside app/views/posts directory.</p>
<p>The show method renders the app/views/posts/show.html.erb file and in the same way the edit method renders the app/views/post/edit.html.erb file.</p>
<p>When you hit <a href="http://localhost:3000/">http://localhost:3000/</a> in your browser you should get the rails default page instead of our home page. That is because rails has created a default index.html page in the public directory. Since we want to use the home controller to show the index page instead of the rails default page ( public/index.html ), we must delete that public/index.html file first:</p>
<pre class="brush: bash;"> $rm public/index.html </pre>
<p>and then tell rails to point to home controller as the default index page. That is done by editing the config/routes.rb file (rails routing)</p>
<h2>Rails routing?</h2>
<p>You can learn more about routing by reading <a href="http://guides.rubyonrails.org/routing.html">Rails Routing from the Outside In</a>.</p>
<p>Edit config/routes.rb in your favorite editor (I prefer emacs)</p>
<pre class="brush: ruby;"> ActionController::Routing::Routes.draw do |map|
map.resources :posts
map.resources :home
map.root :controller =&gt; &quot;home&quot;;
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
</pre>
<p>Note: Whenever a controller is created we need to inform rails about it using the map.resources :  which creates the url say <a href="http://localhost/">http://localhost/</a> in our application.</p>
<p>Also check out the 4th line: map.root :controller =&gt; &#8220;home&#8221; tells rails to load the home controller for the default home page.</p>
<p>Now visit <a href="http://localhost:3000/">http://localhost:3000/</a> and you should see our new home page:</p>
<p><img class="alignnone size-medium wp-image-509" src="http://fuelyourcoding.com/files/image12-600x231.png" alt="image12" width="600" height="231" /></p>
<h2>Conclusion</h2>
<p>So this is just the skeleton of our application. We obviously should add CSS to design our rails application to make everything look better!</p>
<p>I hope this helps you start Ruby on Rails with ease! If you have any queries or are facing any problem while trying out this on your machine please feel free to shout your comments below. ;)</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/creating-your-first-ruby-on-rails-application-from-scratch/">Creating Your First Ruby on Rails Application From Scratch</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=vGJUoI8mwL4:hKH767f0CS4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=vGJUoI8mwL4:hKH767f0CS4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=vGJUoI8mwL4:hKH767f0CS4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=vGJUoI8mwL4:hKH767f0CS4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=vGJUoI8mwL4:hKH767f0CS4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=vGJUoI8mwL4:hKH767f0CS4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=vGJUoI8mwL4:hKH767f0CS4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=vGJUoI8mwL4:hKH767f0CS4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=vGJUoI8mwL4:hKH767f0CS4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=vGJUoI8mwL4:hKH767f0CS4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=vGJUoI8mwL4:hKH767f0CS4:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/vGJUoI8mwL4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/creating-your-first-ruby-on-rails-application-from-scratch/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/creating-your-first-ruby-on-rails-application-from-scratch/</feedburner:origLink></item>
		<item>
		<title>Getting Started with Chyrp</title>
		<link>http://feedproxy.google.com/~r/fuelyourcoding/~3/c1SXxEnT78g/</link>
		<comments>http://fuelyourcoding.com/getting-started-with-chyrp/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 20:38:21 +0000</pubDate>
		<dc:creator>Ethan Turkeltaub</dc:creator>
				<category><![CDATA[Concepts & Training]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[chyrp]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[walkthrough]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=473</guid>
		<description><![CDATA[Instead of using chunky, slow ol' Wordpress, why not use the simpler, faster, solution: Chyrp?<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/getting-started-with-chyrp/">Getting Started with Chyrp</a></p>
]]></description>
			<content:encoded><![CDATA[<p><!-- introduction --></p>
<h2>Introduction</h2>
<p>In the world of web development, when building a blog, you don&#8217;t always want to refer to a slow, over-featured blogging engine like Wordpress. Thankfully, there is a solution, and its name is <a href="http://www.chyrp.net/">Chyrp</a>. Chyrp is a blogging engine that is designed to be extremely lightweight, while still retaining functionality. Alex Suraci, the developer behind Chyrp, codes it in Twig, a language specifically created for this project. The Twig is then put through a compiler and its output is solid PHP.</p>
<p>Before we start, it is important to know how Chyrp is extended: Feathers extend post formats, Modules add functionality, such as a commenting system, and Themes change the look and feel. Keep this in mind.</p>
<p>Interested? Well then, let&#8217;s get started!</p>
<p><img class="alignnone size-medium wp-image-477" src="http://fuelyourcoding.com/files/chyrp1-600x320.jpg" alt="chyrp1" width="600" height="320" /></p>
<h2>Installation</h2>
<p><a href="http://www.chyrp.net/" target="_blank">Download Chyrp</a>, and open up the folder Chyrp v2.0, which should be in the same directory as the archive. Select all the contents and copy and paste it to a directory on your web server (for the purposes of this article, we&#8217;ll be using the /chyrp/ directory). Now would be the time to read the COPYING file, so you don&#8217;t break any copyright laws. You can delete it or keep it, along with the README.markdown file. If your server isn&#8217;t already started, start it. Go to http://localhost/chyrp/ (Or whatever address you use to access your testing server) in your web browser and you should have two errors at the top of the browser window: one for the .htaccess file, and the other for permissions.</p>
<p><img class="alignnone size-medium wp-image-480" src="http://fuelyourcoding.com/files/chyrp4-600x347.jpg" alt="chyrp4" width="600" height="347" /></p>
<p>Go ahead and create the .htaccess file with the contents it shows, and save it in the /chyrp/ directory. You also need to CHMOD the /chyrp/includes/ directory to 777. This means changing the permissions to all read and write. Once you&#8217;ve done that, refresh the web browser page. Now, go ahead and fill in your database information. In this article, we&#8217;ll be using MySQL.</p>
<p>Back at the installation screen, insert your database information. The host is usually localhost. As for a table prefix, we can leave that blank, unless we&#8217;re installing multiple instances of Chyrp on the same database.</p>
<p>Once you filled out the form, hit Install. It fills the database with the information and configures the files within the instance. When it is complete, this page will show:</p>
<p><img class="alignnone size-medium wp-image-478" src="http://fuelyourcoding.com/files/chyrp9-600x344.jpg" alt="chyrp9" width="600" height="344" /></p>
<p>So, delete install.php within /chyrp/, as it poses a security risk if you keep it. If you speak German, you&#8217;re in lucky, because that is the only language pack available at the moment. So now, click Take me to my site! and you&#8217;ll be taken to the home page.</p>
<p>As you can see, there are no posts. Go to the sidebar and click Login, and use your credentials from before. Once that is done, a toolbar will appear in the top. Click the Admin link and you&#8217;ll be taken to the backend.</p>
<h2>Writing in Chyrp</h2>
<p>When you open the backend (it is located at /chyrp/admin/), the Write section is automatically visible. And because Chyrp is a blogging engine, you can make posts and pages. Posts can come in many different forms, such as photos, videos, and plain old text. These different forms come in extensions called Feathers. If you add a photo, you&#8217;ll need the photo Feather in order to do that. The text Feather already comes with Chyrp, and is already activated. The photo, video, link, audio, quote, and chat Feathers already come with the installation, but are not yet activated. We&#8217;ll go through activating them later.</p>
<p>To create a post or page, just select the type on the tabs and type up what you&#8217;d like to say. If you click More Options you can choose a permission status, slug, trackback, timestamp, and pinned status (whether or not you&#8217;d like it as first post, no matter what). Once you&#8217;re done, you can save it, or Publish it. Once you hit Publish, Chyrp will take you to the home page, where you can view your post. It&#8217;s just that easy!</p>
<h2>Manage your Install</h2>
<p>Head back to the backend and click on the Manage tab, near the top. This will bring you to this page:</p>
<p><img class="alignnone size-medium wp-image-481" src="http://fuelyourcoding.com/files/chyrp12-600x287.jpg" alt="chyrp12" width="600" height="287" /></p>
<p>From here you can manage everything about your install. If you click one of the tabs near the middle of the page, you can select what you want to manage. As you add Modules, more tabs will appear.</p>
<p>Modules are ways to extend your install. For example, one Module creates a commenting system, and another allows you to cache pages. We&#8217;ll get into this later.</p>
<p>What you need to focus on in the Manage section is the Groups tab. This allows you to change permissions for groups. Currently, you are part of the Admin group. Click on the edit link (it&#8217;s on the right side) and you&#8217;ll be taken to the page for editing group permissions, as well as the name of the group. Click Save when you&#8217;re done.</p>
<h2>Change the Settings</h2>
<p>The next navigation option is Settings. Under General, you can change your blogs&#8217; name, description, and other settings. Under Content, you can edit posts per page, uploads path, and allowing XML-RPC support. Then, in Users, you can allow r disallow users registering themselves, the default user group, and what group Guests are in (you can even allow all un-registered guests to have Admin permissions, though it is not suggested). Finally, under Routes, you can allow clean URL&#8217;s, which will make the URL&#8217;s formatted as stated in the form below (I highly recommend it—who wants a URL with a question mark in it?).</p>
<h2>Extending your Install</h2>
<p>The Extend section is very important. Extensions are what make Chyrp so very powerful and functional. Modules are very powerful, and the ones that are made by the head developer come with Chyrp. Those are:</p>
<ul>
<li>Textilize</li>
<li>SWFUpload</li>
<li>Paging</li>
<li>Aggregator</li>
<li>Tagginator</li>
<li>Read More</li>
<li>Comment System</li>
<li>Markdown</li>
<li>SmartyPants</li>
<li>Cacher</li>
</ul>
<p><img class="alignnone size-medium wp-image-479" src="http://fuelyourcoding.com/files/chyrp13-600x295.jpg" alt="chyrp13" width="600" height="295" /></p>
<p>All these do exactly what they&#8217;re named for. To activate them, just drag it from the red zone into the green zone. When you do that, a dialog pops up, reminding you to change the permissions. Once you&#8217;ve added all the Modules you want, go back into Manage &gt; Groups and change the permissions so you can manage the Modules.</p>
<p>Now, go ahead and go into the Feathers section. As you can see, the following Feathers come with Chyrp:</p>
<ul>
<li>Photo</li>
<li>Video</li>
<li>Link</li>
<li>Audio</li>
<li>Quote</li>
<li>Chat</li>
</ul>
<p>Plus, the Text Feather, but it is already activated. To activate them, it is the same action as before. If you enable the Photo, Video, or Audio Feather, then you need to create a uploads directory in /chyrp/ and CHMOD it to 777 so you can upload media.</p>
<p>And finally, Themes. The theme that comes with Chyrp is called Stardust. It may be fine for a casual blogger, but for a designer, like me, you need to design your own. That will be in a follow-up article.</p>
<h2>Downloading Extensions</h2>
<p>There are some more extensions on the Chyrp site. There are not many, but the user base is growing rapidly, and so is the development base. To add Feathers, Modules, Themes, etc, just download it and extract the archive to /themes/, /modules/, or /feathers/, respectively. Then, just go into the backend and activate it. It&#8217;s just that simple.</p>
<h2>Chyrp vs. Wordpress</h2>
<p>You may be questioning, “Why Chyrp? Why not just go with the popular solution: Wordpress?” Well, why Wordpress? There are a lot of functions in Wordpress that you&#8217;ll never need or use, so why have them. A fresh Chyrp install is bare bones, and you&#8217;re free to install what you need. Plus, Chyrp is a lot faster than Wordpress, on the front and backend.</p>
<p>As well as speed, Chyrp has better code than Wordpress—Alex (founder and sole core-developer) uses Ruby on Rails and Python helpers to have perfect code that is easy to edit.</p>
<p>While retaining functionality, Chyrp is more flexible than Wordpress. It can do a lot of different functions, and is easy to mod to your hearts content.</p>
<p>So why use Wordpress?</p>
<h2>The Chyrp Community and Support</h2>
<p>Chyrp has a strong community and support group. In the <a href="http://www.chyrp.net/discuss">Discuss section of the Chyrp site</a>, you can ask for help or just discuss&#8230; whatever. Or, to get instant help, log on to good ol&#8217; IRC on irc://freenode.org/chyrp (that would be irc.freenode.org as the server, then #chyrp as the channel).</p>
<p><!-- /support --></p>
<p>In the next article, we&#8217;ll be building a custom theme!</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://d1.openx.org/ck.php?oaparams=2__bannerid=139646__zoneid=0__log=no__cb=0e36172e31__r_id=__r_ts=__oadest=http%3A%2F%2Ffuelbrandnetwork.com' target='_blank'><img src='http://d1.openx.org/avw.php?zoneid=64727&amp;cb=675189657412&amp;n=aa69fdf4' border='0' alt='' /></a>
<p><a href="http://www.fuelyourcoding.com/advertise/">Advertise on Fuel Your Coding</a>. <br />
  <a href="http://www.fuelyourcoding.com">Fuel Your Coding</a> 2009 <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">cc</a> (creative commons license)
</p></p>
<p><a href="http://fuelyourcoding.com/getting-started-with-chyrp/">Getting Started with Chyrp</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=c1SXxEnT78g:irdSF8Z0-gU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=c1SXxEnT78g:irdSF8Z0-gU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=c1SXxEnT78g:irdSF8Z0-gU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=c1SXxEnT78g:irdSF8Z0-gU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=c1SXxEnT78g:irdSF8Z0-gU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=c1SXxEnT78g:irdSF8Z0-gU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=c1SXxEnT78g:irdSF8Z0-gU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=c1SXxEnT78g:irdSF8Z0-gU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=c1SXxEnT78g:irdSF8Z0-gU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?i=c1SXxEnT78g:irdSF8Z0-gU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/fuelyourcoding?a=c1SXxEnT78g:irdSF8Z0-gU:TzevzKxY174"><img src="http://feeds.feedburner.com/~ff/fuelyourcoding?d=TzevzKxY174" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/fuelyourcoding/~4/c1SXxEnT78g" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/getting-started-with-chyrp/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://fuelyourcoding.com/getting-started-with-chyrp/</feedburner:origLink></item>
	</channel>
</rss>
