<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Fuel Your Coding &#187; PHP</title>
	<atom:link href="http://fuelyourcoding.com/category/languages/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://fuelyourcoding.com</link>
	<description></description>
	<lastBuildDate>Mon, 09 Aug 2010 14:40:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WordPress: Auto URL Shortening</title>
		<link>http://fuelyourcoding.com/wordpress-auto-url-shortening/</link>
		<comments>http://fuelyourcoding.com/wordpress-auto-url-shortening/#comments</comments>
		<pubDate>Mon, 24 May 2010 12:39:29 +0000</pubDate>
		<dc:creator>Designerfoo</dc:creator>
				<category><![CDATA[Languages]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[bitly]]></category>
		<category><![CDATA[Plugins / Add-Ons]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=985</guid>
		<description><![CDATA[Everyday there are scores of new links shared, re-tweeted, posted, and emailed by people like you and I. Because of social media platforms like Twitter and Facebook, our love for sharing information, tutorials, freebies, etc., has never been stronger!
The Proposition
As a WordPress developer/designer, how would you like if URLs on your WordPress site were automatically [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/wordpress-auto-url-shortening/">WordPress: Auto URL Shortening</a></p>
]]></description>
			<content:encoded><![CDATA[<p><img src="http://fuelyourcoding.com/files/urlshortner_mini.jpg" alt="WP Auto URL Shortening" title="WP Auto URL Shortening" width="250" height="188" class="alignright size-full wp-image-1031" />Everyday there are scores of new links shared, re-tweeted, posted, and emailed by people like you and I. Because of social media platforms like Twitter and Facebook, our love for sharing information, tutorials, freebies, etc., has never been stronger!</p>
<h2>The Proposition</h2>
<p>As a <a href="http://wordpress.org">WordPress</a> developer/designer, how would you like if URLs on your WordPress site were automatically shortened as soon as you publish? This would mean instantly available shortened URLs for sharing/posting AND statistics of your links!</p>
<h2>Here&#8217;s How</h2>
<p>We are going to build the Auto URL Shortening feature within your WordPress theme using the <a href="http://bit.ly/">bit.ly</a> API. Let&#8217;s start with the <tt>functions.php</tt> file found within your theme.</p>
<p>The <tt>functions.php</tt> file is included in most WordPress themes as a place to drop custom functions to be used from the theme. If this file doesn&#8217;t exist in the theme you are using, go ahead and create it.</p>
<h3>Add 3 functions within the functions.php file</h3>
<pre class="brush: php;">
function makeshorturl()
{

}

function shorturl_metabox()
{

}

function showshorturlbox()
{

}
</pre>
<p>The first function, <tt>makeshorturl()</tt>, as the name suggests will be creating a short URL for us. The second and the third functions will work together to show us the short URL in the admin editor.</p>
<h3>Shortening the link</h3>
<pre class="brush: php;">
function makeshorturl()
{
    global $post;

    $short_url = json_decode(file_get_contents('http://api.bit.ly/v3/shorten?login=[username]&amp;apiKey=[apikey]&amp;longURL='.urlencode(get_permalink($post-&gt;ID)).'&amp;format=json'));

    if($short_url-&gt;status_code==&quot;200&quot;)
    {
         $short_url = $short_url-&gt;data-&gt;url;
    }
    else
    {
        $short_url = &quot;Bit.ly Error! &quot;.$short_url-&gt;status_txt;
    }

    do_action('makeshorturl');

    return $short_url;
}
</pre>
<p>The first line in this function declares WordPress&#8217;s global <tt>$post</tt> variable which holds all the data for the current post. We extract the permalink of the current post using the <tt>get_permalink()</tt> function and supplying the current post&#8217;s id. We then take the permalink and pass it on to bit.ly&#8217;s API which returns us a short URL within a JSON object. Next we extract the short URL. If an error occurs we simply return the error.</p>
<p>The <tt>do_action()</tt> method in WordPress makes this function hookable with other functions/hooks and the function can be used within theme using the hook &#8211; <strong>makeshorturl()</strong>.</p>
<p>Want to know more about <a href="http://codex.wordpress.org/Function_Reference/do_action" target="_new" rel="nofollow">do_action()</a> and <a href="http://codex.wordpress.org/Plugin_API"  target="_new" rel="nofollow">wordpress hooks</a>?</p>
<h3>Lets look at the api call in more detail</h3>
<pre class="brush: php;">
http://api.bit.ly/v3/shorten?login=[username]&amp;apiKey=[apikey]&amp;longURL='.urlencode(get_permalink($post-&gt;ID)).'&amp;format=json
</pre>
<p>It&#8217;s really quite simple.</p>
<p>The <tt>login</tt> parameter would expect your login over at bit.ly (<a href="http://bit.ly/a/sign_up" target="_new" rel="nofollow">don&#8217;t have one? create one here</a>). The <tt>apiKey</tt> parameter accepts the API key given to each bit.ly account. If you already have an account you can find <a href="http://bit.ly/a/your_api_key" target="_new" rel="nofollow">the API key here</a>. The <tt>longURL</tt> parameter expects an encoded long URL string that needs to be shortened, and this is where our custom permalinks get passed. The <tt>format</tt> parameter expects one of the three values &#8211; json, xml or text; depending on the format value specified, the API returns the shortened url (and more data) as JSON, XML or text respectively. By default, if format is not specified, it returns a JSON object. For more info on the bit.ly API, refer the <a href="http://code.google.com/p/bitly-api/wiki/ApiDocumentation">API documentation</a>. Once the bit.ly API sends the JSON object back, we use PHP&#8217;s <tt>json_decode</tt> function to decode the JSON object into a PHP5 object.</p>
<h3>Adding the shortened URL to the admin editor</h3>
<p>Once the permalink has been shortened, we need to make it available in the backend. To do this, we use the two functions as outlined below.</p>
<pre class="brush: php;">
function shorturl_metabox()
{
    if(is_admin())
    {
        add_meta_box('bitlyurl',__('Short URL','short-url'),'showshorturlbox','post','side');
        add_meta_box('bitlyurl',__('Short URL','short-url'),'showshorturlbox','page','side');
    }
}
</pre>
<p>The <tt>shorturl_metabox</tt> will first check if the user is within the admin section of the wordpress based site/blog. Then we add a meta box to the admin page.</p>
<p><img src="http://fuelyourcoding.com/files/shorturlmaker.png" alt="Short URL Admin" title="Short URL Admin" width="297" height="79" class="alignleft size-full wp-image-1019" /> A Meta box in WordPress basically is a box which sets and gets meta information about a post. Default meta boxes include Post Tags, Discussions and so forth. </p>
<p><a href="http://codex.wordpress.org/Writing_Posts" target="_new" rel="nofollow">More on meta boxes.</a></p>
<p>The <tt>add_meta_box</tt> function takes five parameters:</p>
<ol>
<li> the HTML id of the box</li>
<li>the label/title of the box</li>
<li>the callback function which would render the box contents</li>
<li>the type of write screen &#8211; post or a page
</li>
<li>the position or context where the box would be located &#8211; Normal, Advanced or Side.</li>
</ol>
<p><a href="ttp://codex.wordpress.org/Function_Reference/add_meta_box" target="_new" rel="nofollow">More on add_meta_box()</a>.</p>
<p>As you can see, that when the function &#8220;<em>adds</em>&#8221; the meta box to the admin view, it calls the <tt>showshorturlbox</tt> function which renders the contents of the meta box, as shown below.</p>
<pre class="brush: php;">
function showshorturlbox()
{
    echo '&lt;label for=&quot;bitlyurl&quot;&gt;'.__('Shortened URL','short-url-label').': '.makeshorturl().'&lt;/label&gt;&lt;br/&gt;&lt;br/&gt;';
}
</pre>
<p>The function echoes the short URL in a label, thus making it available to be shared by the authors of the post/page. We are calling <tt>makeshorturl()</tt> which fetches or generates the shortened URL via the bitly API.</p>
<h3>Bringing it together</h3>
<p>Finally we use the following three lines which attach our <tt>makeshorturl()</tt> function to the <tt>publish_post</tt> and <tt>publish_page</tt> hooks and attaches <tt>shorturl_metabox</tt> to the <tt>do_meta_boxes</tt> hook that generates the meta boxes.</p>
<pre class="brush: php;">
add_action('publish_post','makeshorturl');
add_action('publish_page','makeshorturl');
add_action('do_meta_boxes','shorturl_metabox');
</pre>
<h3>Complete Code within functions.php</h3>
<pre class="brush: php;">
function makeshorturl()
{
global $post;

$short_url = json_decode(file_get_contents('http://api.bit.ly/v3/shorten?login=[username]&amp;apiKey=[apikey]&amp;longURL='.urlencode(get_permalink($post-&gt;ID)).'&amp;format=json'));

if($short_url-&gt;status_code==&quot;200&quot;)
    {
         $short_url = $short_url-&gt;data-&gt;url;
    }
    else
    {
        $short_url = &quot;Bit.ly Error! &quot;.$short_url-&gt;status_txt;
    }
    do_action('makeshorturl');
    return $short_url;
}

function shorturl_metabox()
{
    if(is_admin())
    {
        add_meta_box('bitlyurl',__('Short URL','short-url'),'showshorturlbox','post','side');
        add_meta_box('bitlyurl',__('Short URL','short-url'),'showshorturlbox','page','side');
    }
}

function showshorturlbox()
{
    echo '&lt;label for=&quot;bitlyurl&quot;&gt;'.__('Shortened URL','short-url-label').': '.makeshorturl().'&lt;/label&gt;&lt;br/&gt;&lt;br/&gt;';
}

add_action('publish_post','makeshorturl');
add_action('publish_page','makeshorturl');
add_action('do_meta_boxes','shorturl_metabox');
</pre>
<h3>Usage</h3>
<p>If you did like to show off the shortened URL to your users simply insert this code where you want the short URL to show up:</p>
<pre class="brush: php;">
&lt;?php echo makeshorturl(); ?&gt;
</pre>
<h2>BONUS</h2>
<p>Want a ready-to-use solution? Here&#8217;s the plugin version of the above code that will generate the shortened URLs on the fly for you to share. If you did like to call the functions from within the theme template, you can do so by using: </p>
<pre class="brush: php;">
&lt;?php echo wps_hook(); ?&gt;
</pre>
<p><em><strong>Note: </strong>Above tag is for the plugin only. </em></p>
<p><em>PS:</em> The plugin can also show number of clicks on a shortened link :) per shortened URL</p>
<h3>Download it!</h3>
<p><a href="http://fuelyourcoding.com/files/wp_shorturlmaker.zip" rel="nofollow"><img src="http://fuelyourcoding.com/files/downloadplugin1.jpg" alt="Download Plugin - WP Short URL Maker" title="Download Plugin - WP Short URL Maker" width="300" height="60" class="alignleft size-full wp-image-1043" border="0"/></a></p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/wordpress-auto-url-shortening/">WordPress: Auto URL Shortening</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/wordpress-auto-url-shortening/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Meet Storytlr</title>
		<link>http://fuelyourcoding.com/meet-storytlr/</link>
		<comments>http://fuelyourcoding.com/meet-storytlr/#comments</comments>
		<pubDate>Mon, 10 May 2010 14:08:17 +0000</pubDate>
		<dc:creator>John Hobbs</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Languages]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=932</guid>
		<description><![CDATA[What is Storytlr?
Lifestreaming is the aggregation of all of your actions throughout the web in one place to present a complete picture of your digital life. There are several lifestreaming applications out there, and Storytlr was one of the first.
Storytlr was originally a closed source, hosted web application started by Laurent Eschenauer and Alard Weisscher [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/meet-storytlr/">Meet Storytlr</a></p>
]]></description>
			<content:encoded><![CDATA[<h2>What is Storytlr?</h2>
<p><a href="http://en.wikipedia.org/wiki/Lifestreaming">Lifestreaming</a> is the aggregation of all of your actions throughout the web in one place to present a complete picture of your digital life. There are several lifestreaming applications out there, and <a href="http://storytlr.org/">Storytlr</a> was one of the first.</p>
<p>Storytlr was originally a closed source, hosted web application started by Laurent Eschenauer and Alard Weisscher in 2008. In October 2009 they decided to close the service and in December they open sourced the code.</p>
<p>Considerable community development has occurred since the project was open sourced, including many new plugins, bug fixes and features.</p>
<h2>Installing Storytlr</h2>
<p>Storytlr is written in PHP and based around the <a href="http://framework.zend.com/">Zend</a> framework. It is usually run on Apache, but works fine on lighttpd and Nginx. The current stable release is 0.9.2, although there is an RC 0.9.3 that works well.  Additionally you can use the bleeding edge code on <a href="http://github.com/storytlr/core">GitHub</a>.  I currently maintain my own version of 0.9.3 that has a few more features and plugins you won&#8217;t find in the core. You can find it <a href="http://github.com/jmhobbs/storytlr">here</a>.</p>
<p>Since it&#8217;s coming out of a close source system, expect some rough edges and thin documentation.  This is improving all the time with the growing <a href="http://code.google.com/p/storytlr/wiki/WikiHome?tm=6">wiki</a> and the <a href="http://code.google.com/p/storytlr/issues/list">issues board</a>.  Installation is still one of those rough edges, but it&#8217;s fairly easy anyway.</p>
<p>For simplicity I&#8217;ll be using the 0.9.2 release from the <a href="http://code.google.com/p/storytlr/downloads/list">Google Code site</a>, but these instructions can be easily adapted to other versions.  I&#8217;ll be doing just about everything from the command line, so if you don&#8217;t have shell access, be prepared to tweak things a bit.</p>
<h3>Requirements</h3>
<p>First, let&#8217;s make sure our server is compatible.  0.9.2 has the following requirements:</p>
<ul>
<li>PHP 5</li>
<li>mcrypt</li>
<li>PDO</li>
<li>Tidy</li>
<li>MySQL</li>
<li>Zend Framework</li>
</ul>
<p>An easy way to check compatibility is to use <a href="http://gist.github.com/raw/393739/storytlr_requirements_check.php">this script</a>.</p>
<p>Most hosts have these extensions. The rarest one is Tidy.  For instance, Dreamhost does not run Tidy.  If your host doesn&#8217;t have Tidy, you can work around it by using a different version with the <a href="http://code.google.com/p/storytlr/issues/detail?id=64&amp;can=1&amp;q=htmLawed#c1">htmLawed patch</a>.</p>
<p>If you are missing Zend, that can be downloaded <a href="http://framework.zend.com/download/current/">here</a>. Make sure to put it in your PHP include path.</p>
<h3>Getting Started</h3>
<p>Now that you&#8217;ve got the requirements met, download the <a href="http://code.google.com/p/storytlr/downloads/list">0.9.2 file</a> and unpack it into your root web directory.</p>
<pre class="brush: bash;">
jmhobbs@katya:/var/www/lifestream$ wget http://storytlr.googlecode.com/files/storytlr-0.9.2.tgz
--2010-05-07 13:33:05--  http://storytlr.googlecode.com/files/storytlr-0.9.2.tgz
Resolving storytlr.googlecode.com... 74.125.45.82
Connecting to storytlr.googlecode.com|74.125.45.82|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8748114 (8.3M) [application/x-gzip]
Saving to: “storytlr-0.9.2.tgz”

100%[============================================&gt;] 8,748,114    233K/s   in 36s

2010-05-07 13:33:41 (239 KB/s) - “storytlr-0.9.2.tgz” saved [8748114/8748114]

jmhobbs@katya:/var/www/lifestream$ tar -zxf storytlr-0.9.2.tgz
jmhobbs@katya:/var/www/lifestream$ ls -a
.  ..  feeds  flash  friendconnect  .htaccess  images  index.php  INSTALL  js  LICENSE  protected  storytlr-0.9.2.tgz  style  themes
jmhobbs@katya:/var/www/lifestream$
</pre>
<h3>The Database</h3>
<p>Now you need to load the database schema. The schema files is located at <tt>protected/install/database.sql</tt>.  If you don&#8217;t have a database or user set up, now is the time to do that as well.</p>
<pre class="brush: bash;">
jmhobbs@katya:/var/www/lifestream$ cd protected/install/
jmhobbs@katya:/var/www/lifestream/protected/install$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5515
Server version: 5.0.81-1 (Debian)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql&gt; create database lifestream;
Query OK, 1 row affected (0.05 sec)

mysql&gt; grant all on lifestream.* to lifestream@localhost identified by 'supersecretpassword';
Query OK, 0 rows affected (0.11 sec)

mysql&gt; flush privileges;
Query OK, 0 rows affected (0.08 sec)

mysql&gt; use lifestream;
Database changed
mysql&gt; source database.sql
Query OK, 0 rows affected (0.00 sec)

(Lines Removed For Brevity)

Query OK, 0 rows affected (0.00 sec)

mysql&gt; Bye
jmhobbs@katya:/var/www/lifestream/protected/install$
</pre>
<h3>Configuration</h3>
<p>Your last major step is the configuration file, which goes at <tt>protected/config/config.ini</tt>.  Storytlr provides an example file with good defaults, so we&#8217;ll edit that.  The key settings to change are:</p>
<ul>
<li>db.username</li>
<li>db.password</li>
<li>db.dbname</li>
<li>security.cookie</li>
<li>web.host</li>
<li>web.timezone</li>
</ul>
<pre class="brush: bash;">
jmhobbs@katya:/var/www/lifestream$ cd protected/config/
jmhobbs@katya:/var/www/lifestream/protected/config$ ls
config.ini.sample
jmhobbs@katya:/var/www/lifestream/protected/config$ cp config.ini.sample config.ini
jmhobbs@katya:/var/www/lifestream/protected/config$ vim config.ini

[general]

;Database connection settings
db.adapter=PDO_MYSQL
db.host=localhost
db.username=lifestream
db.password=supersecretpassword
db.dbname=lifestream

;Security
security.cookie = kg89y6gbval

;Caching
;cache.content = 1
;cache.metadata = 1
;cache.path = /tmp/cache/

;Web deployment settings
web.host=lifestream.velvetcache.org
web.path=/
web.redirect = 1
web.timezone=America/Chicago
jmhobbs@katya:/var/www/lifestream/protected/config$
</pre>
<h3>The Fruits of Our Labor</h3>
<p>At this point your lifestream should be working, open a browser and take a look.</p>
<p><img class="alignnone size-medium wp-image-934" title="It Works!" src="http://fuelyourcoding.com/files/storytlr-1-600x429.png" alt="It Works!" width="600" height="429" /></p>
<p>Now we need to change our password, so go to the admin page <tt>http://www.example.com/admin</tt> and log in. The default username and password are <tt>admin</tt> and <tt>storytlr</tt> respectively.  You can find that under <strong>Configure » Password</strong>.</p>
<p><img class="alignnone size-medium wp-image-936" title="Change Password" src="http://fuelyourcoding.com/files/storytlr-3-600x429.png" alt="Change Password" width="600" height="429" /></p>
<p>There are lots of options to browse through, and I won&#8217;t cover them all, but I&#8217;d like to run through setting up a source. Sources are the core of lifestreaming, and there are lots of options to choose from. In the admin interface go to <strong>Sources</strong> and click <strong>Add</strong> next to a source you want to add, I&#8217;ll use Delicious in my example.</p>
<p>This should present you with a form asking for some information. Each source is going to be slightly different, but all should be pretty easy to understand. Fill that out and it should import what it can from that source.</p>
<p><img class="alignnone size-medium wp-image-938" title="Delicious" src="http://fuelyourcoding.com/files/storytlr-5b-600x429.png" alt="Delicious" width="600" height="429" /></p>
<p><img class="alignnone size-medium wp-image-939" title="Importing" src="http://fuelyourcoding.com/files/storytlr-6b-600x429.png" alt="Importing" width="600" height="429" /></p>
<p>There you have it! Add some more sources until your lifestream really fleshes out.</p>
<p><img class="alignnone size-medium wp-image-940" title="Lifestream!" src="http://fuelyourcoding.com/files/storytlr-8b-600x429.png" alt="Lifestream!" width="600" height="429" /></p>
<h3>Keeping Current</h3>
<p>The very last step, which is often overlooked, is updating your sources. The primary means for this is the PHP script <tt>protected/tools/update.php</tt>. This must be run from the command line with the name of the user to update.  Here&#8217;s an example:</p>
<pre class="brush: bash;">
jmhobbs@katya:/var/www/lifestream$ php5 protected/tools/update.php admin
Memory usage on startup: 4997940
Memory: 5351904
Memory: 5351904
Updating source delicious for user admin [0/2] (5).... found 0 items
Updated 1 out of 2 sources in 1 seconds.
jmhobbs@katya:/var/www/lifestream$
</pre>
<p>It&#8217;s common to set up a cron job to handle these updates. It&#8217;s often important to put in full paths for your cron jobs.  This example will update my sources every 10 minutes. You can learn more about cron <a href="http://www.linuxhelp.net/guides/cron/">here</a>.</p>
<pre class="brush: bash;">
jmhobbs@katya:/var/www/lifestream$ crontab -e
MAILTO=jmhobbs@towncommons.com
# m h  dom mon dow   command
*/10 * * * * /usr/bin/php5 /var/www/lifestream/protected/tools/update.php admin
jmhobbs@katya:/var/www/lifestream$
</pre>
<p>Storytlr has lots more features and configuration options, I would encourage you to browse around and make your installation suit your taste. To see an example of a fully customized Storytlr installation, you can visit mine at <a href="http://lifestream.velvetcache.org/">http://lifestream.velvetcache.org/</a></p>
<h2>Going Further</h2>
<p>Storytlr is rich with opportunities to contribute. It&#8217;s fairly young and has lots of finicky little things to figure out, and it can always use one more plugin.  Lots of stuff is in the works, including a much simpler installer which will make most of this article obsolete!</p>
<p>Documentation is in need of some TLC, and more eyes on the bug reports would be great.</p>
<p>To get involved visit the <a href="http://code.google.com/p/storytlr">Storytlr Google Code</a> site or hop onto Github and <a href="http://github.com/storytlr/core">fork the project</a>.  Finally, you can also join us on Freenode IRC in <a href="irc://chat.freenode.net/storytlr">#storytlr</a>.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/meet-storytlr/">Meet Storytlr</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/meet-storytlr/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple Debugging with WordPress</title>
		<link>http://fuelyourcoding.com/simple-debugging-with-wordpress/</link>
		<comments>http://fuelyourcoding.com/simple-debugging-with-wordpress/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 19:13:36 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Concepts & Training]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[wp_debug]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=826</guid>
		<description><![CDATA[For simple WordPress theme development, what is the first thing most PHP developers do to troubleshoot problems?

print_r( $post );
die();

One the statements are in place, the programmer refreshes the page and looks at the source to view a nicely indented array or object. Next they comment out the print_r and die statements, change some lines, and [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/simple-debugging-with-wordpress/">Simple Debugging with WordPress</a></p>
]]></description>
			<content:encoded><![CDATA[<p>For simple WordPress theme development, what is the first thing most PHP developers do to troubleshoot problems?</p>
<pre class="brush: php;">
print_r( $post );
die();
</pre>
<p>One the statements are in place, the programmer refreshes the page and looks at the source to view a nicely indented array or object. Next they comment out the <tt>print_r</tt> and <tt>die</tt> statements, change some lines, and try the code again. If it fails, they are back to square one and in go the <tt>print_r</tt>,<tt>echo</tt> and <tt>die</tt> statements so the brutal cycle can begin again.</p>
<p>We know these methods <em>partially</em> work (who hasn&#8217;t done the above during a PHP project!), but we also know they are less than optimal. Is there a better way?</p>
<h2>WordPress Debug Mode</h2>
<p>WordPress offers quite a few ways to enable and customize a debug mode while developing. To enable debug mode, you want to define <tt>WP_DEBUG</tt> as <tt>true</tt> in your wp-config.php. Here is the complete code block I suggest you use. We will look at the individual parts shortly. Place this in your <tt>wp-config.php</tt> file after the lines that define the database variables. Be sure to change <tt>development_user</tt> to be your development database user name:</p>
<pre class="brush: php;">
@ini_set('display_errors',0);
if( 'development_user' === DB_USER ){
  define('WP_DEBUG',         true);  // Turn debugging ON
  define('WP_DEBUG_DISPLAY', false); // Turn forced display OFF
  define('WP_DEBUG_LOG',     true);  // Turn logging to wp-content/debug.log ON
}
</pre>
<h3>display_errors</h3>
<p>The first line in our code block turns off the display of errors, regardless of php.ini or .htaccess settings to the contrary. This is important because though WordPress can force the display of errors to be on, it won&#8217;t force them to be off if <tt>display_errors</tt> is already turned on.</p>
<h3>Testing for local vs. production</h3>
<p>There are probably fifty ways of doing this part, so use a method that works for you. In my environments, my local development database rarely if <em>ever</em> has the same user name as the production database. Simply checking what I expect the local user name to be against what is defined in <tt>DB_USER</tt> is a simple way of knowing if the files are on the development or production servers.</p>
<h3>WP_DEBUG</h3>
<p>This is the most important constant as it determines if WordPress will use any of the other debugging constants. Thankfully it is quite simple. If set to <tt>true</tt>, debug mode is turned on. If <tt>undefined</tt> or set to <tt>false</tt>, debug mode is kept off.</p>
<h3>WP_DEBUG_DISPLAY</h3>
<p>This constant confused me at first, but it is actually quite simple. If set to <tt>true</tt>, it will override the current <tt>display_errors</tt> configuration setting and turn it on. However, if set to <tt>false</tt> it <strong>will not turn off <tt>display_errors</tt>.</strong> This setting is simply an override. This is the reason we turn <tt>display_errors</tt> off before setting any of these constants.</p>
<p>Set this constant to <tt>true</tt> if you want to see errors displayed in your browser when they occur. Keep in mind this will sometimes complicate errors because once at least one error has been written to the page, all redirect requests will fail. This is because the header information can no longer be modified once content is sent, and a displayed error counts as content.</p>
<h3>WP_DEBUG_LOG</h3>
<p>This constant is the whole reason I found the WordPress debug methods so helpful. Set this constant to <tt>true</tt> and WordPress will set up PHP to write to an error log in <tt>wp-content/debug.log</tt>. Sadly you can&#8217;t specify a different file location that is not in the content folder, but at least you know where it is!</p>
<p><em>Note: because this is written to a public directly, be extremely careful not to upload the log by mistake. Additionally, if you run WP_DEBUG on a production server, do so only for immediate troubleshooting then turn it off and remove <tt>wp-content/debug.log</tt>.</em></p>
<h2>Leveraging WP_DEBUG</h2>
<p>In addition to PHP errors being sent to <tt>debug.log</tt> we can also send our own output using the <tt>error_log</tt> PHP function. The only problem with this, is even in production mode your errors will still most likely be written to a PHP log; it just won&#8217;t be <tt>debug.log</tt>. Because of this, its a good idea to provide a wrapper function to handle the logging for your theme or plugin.</p>
<p>Place the following code in your <tt>functions.php</tt> in your theme, or in the plugin file for your WordPress plugin:</p>
<pre class="brush: php;">
if(!function_exists('_log')){
  function _log( $message ) {
    if( WP_DEBUG === true ){
      if( is_array( $message ) || is_object( $message ) ){
        error_log( print_r( $message, true ) );
      } else {
        error_log( $message );
      }
    }
  }
}
</pre>
<p>Feel free to expand on this function if it doesn&#8217;t exactly meet your needs, but the concept is simple: Centralize all your log calls to use your custom function. Then, in that <tt>_log</tt> function, only output the message if <tt>WP_DEBUG</tt> is set to <tt>true</tt>. There is no reason to test if <tt>WP_DEBUG</tt> has been defined because as soon as <tt>wp-settings.php</tt> is processed, <tt>WP_DEBUG</tt> <em>will be</em> defined, even if it wasn&#8217;t already defined in <tt>wp-config.php</tt>.</p>
<p>This particular <tt>_log</tt> snippet will call a <tt>print_r</tt> on arrays and objects passed to the function for simple debugging.</p>
<h2>Trying it Out</h2>
<p>If you have followed these steps, you can run a quick test by adding these lines into your <tt>header.php</tt> file in your theme folder:</p>
<pre class="brush: php;">
_log('Testing the error message logging');
_log(array('it' =&gt; 'works'));
</pre>
<p>After refreshing your page once, you should see a newly created <tt>debug.php</tt> file with a few lines of output. Use any log viewing utility that supports tailing the file for maximum productivity. On Mac, Unix and Linux systems, you can use this command from the main directory of your site:</p>
<pre class="brush: plain;">
tail -f wp-content/debug.log
</pre>
<h2>More Solutions</h2>
<p>If you are looking for a more interactive console for debugging, be sure to look at our review on the <a href="http://fuelyourcoding.com/plugin-review-wordpress-console/">WordPress Console</a>.</p>
<p><strong>What about you?</strong> If you didn&#8217;t already know about this built in WordPress feature, what methods did you come up with to make debugging WordPress easier? Please leave us your tips in the comments below!</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/simple-debugging-with-wordpress/">Simple Debugging with WordPress</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/simple-debugging-with-wordpress/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Roll Your Own PHP Framework: Part III</title>
		<link>http://fuelyourcoding.com/roll-your-own-php-framework-part-iii/</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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/roll-your-own-php-framework-part-iii/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Easy to update thumbnail gallery using Textpattern and Galleriffic</title>
		<link>http://fuelyourcoding.com/easy-to-update-thumbnail-gallery-using-textpattern-and-galleriffic/</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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/easy-to-update-thumbnail-gallery-using-textpattern-and-galleriffic/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Roll Your Own PHP Framework: Part II</title>
		<link>http://fuelyourcoding.com/roll-your-own-php-framework-part-ii/</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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/roll-your-own-php-framework-part-ii/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>PHP Frameworks? Just roll your own! &#8211; PART 1</title>
		<link>http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/</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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/php-frameworks-just-roll-your-own-part-1/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Create a Simple Portfolio Website and Blog with Textpattern</title>
		<link>http://fuelyourcoding.com/create-a-simple-portfolio-website-and-blog-with-textpattern/</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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/create-a-simple-portfolio-website-and-blog-with-textpattern/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Getting Started with Chyrp</title>
		<link>http://fuelyourcoding.com/getting-started-with-chyrp/</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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/getting-started-with-chyrp/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>WordPress hack: Adding a bio block to a post</title>
		<link>http://fuelyourcoding.com/wordpress-hack-adding-a-bio-block-to-a-post/</link>
		<comments>http://fuelyourcoding.com/wordpress-hack-adding-a-bio-block-to-a-post/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 18:10:55 +0000</pubDate>
		<dc:creator>Gaya Kessler</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins / Add-Ons]]></category>
		<category><![CDATA[bio]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=217</guid>
		<description><![CDATA[If you have multiple writers on your blog or if you are accepting guest articles and you want to give this person some exposure, a little box containing a short bio will do perfectly.
The only problem is that bios are not standard in WordPress. This article will tell you how to hack your own bio [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/wordpress-hack-adding-a-bio-block-to-a-post/">WordPress hack: Adding a bio block to a post</a></p>
]]></description>
			<content:encoded><![CDATA[<p>If you have multiple writers on your blog or if you are accepting guest articles and you want to give this person some exposure, a little box containing a short bio will do perfectly.</p>
<p>The only problem is that bios are not standard in WordPress. This article will tell you how to hack your own bio box into WordPress without using a single plugin! A great way to start developing in WordPress.</p>
<h2>Hack your template</h2>
<p>First thing we need to do is to hack a file in your theme&#8217;s template. The file we want to edit is called &#8220;single.php&#8221; in most WordPress themes.</p>
<p>Open up this file.</p>
<p>This is the template file that shows a single post. Typically the template file has the following code somewhere &#8220;the_content()&#8221; looks for this.<br />
Beneath this line of code paste the following:</p>
<pre class="brush: php;">
&lt;?php
if (get_post_custom_values(&quot;bio&quot;)) {
?&gt;

&lt;div class='writer_bio'&gt;
&lt;img src='&lt;?php the_author_aim(); ?&gt;' alt='' /&gt;
&lt;?php the_author_description(); ?&gt;
&lt;/div&gt;
&lt;?php
}
?&gt;
</pre>
<h2>Adding a bio to a writer</h2>
<p>We now want to add / edit writers, you can create them in the user panel of WordPress. I am guessing you are already using this to display the author&#8217;s name on your blog. We can use the fields available per user to set the bio.</p>
<p>Go and edit an existing user that has an article posted (You can change the user that posted the article when you edit an article.)<br />
Now fill in the &#8220;Biographical Info&#8221; text area with the HTML to go into the bio block.</p>
<p>My bio, for example is: &#8220;Gaya Kessler is a 21 year old web developer writing about a kinds of thing. He&#8217;s the editor of &lt;a href=&#8221;http://www.fuelyourcoding.com&#8221;&gt;Fuel Your Coding&lt;/a&gt; and owner of &lt;a href=&#8221;http://www.gayadesign.com&#8221;&gt;Gaya Design&lt;/a&gt;. You can also &lt;a href=&#8221;http://www.twitter.com/gayadesign&#8221;&gt;catch him on twitter&lt;/a&gt;.&#8221;</p>
<p>To add the avatar we need to fill in the &#8220;aim&#8221; field. I am not using this field anywhere in the theme, but now I am going to use it in the bio. Put the absolute path to the image here, eg: &#8220;http://fuelyourcoding.com/files/writer-rob.png&#8221;.</p>
<p>Now all there is left to do is enable the bio on a post. To do this you only need to add a custom field to a post.<br />
Go to a post you want to add bio to and create a name custom field called &#8220;bio&#8221; and give it the value &#8220;1&#8243;.</p>
<p>If all went well the bio should now be visible in that post!</p>
<h2>Is that all?</h2>
<p>Jep! The hacking is done.</p>
<p>You might want to add some styling though, to make it more appealing to the eye.</p>
<p>Good luck with this easy hack!</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/wordpress-hack-adding-a-bio-block-to-a-post/">WordPress hack: Adding a bio block to a post</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/wordpress-hack-adding-a-bio-block-to-a-post/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Getting Started Writing WordPress Plugins</title>
		<link>http://fuelyourcoding.com/getting-started-writing-wordpress-plugins/</link>
		<comments>http://fuelyourcoding.com/getting-started-writing-wordpress-plugins/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 17:41:29 +0000</pubDate>
		<dc:creator>Douglas Neiner</dc:creator>
				<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins / Add-Ons]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=189</guid>
		<description><![CDATA[Why WordPress?
For those who use WordPress on a daily basis, this is a no-brainer. However, as everyone seems to have their own pet CMS, it is sometimes hard for them to understand why anyone would use WordPress for something other than just a blogging platform. I am sure there are many pros and cons, but [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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-writing-wordpress-plugins/">Getting Started Writing WordPress Plugins</a></p>
]]></description>
			<content:encoded><![CDATA[<h2>Why WordPress?</h2>
<p>For those who use WordPress on a daily basis, this is a no-brainer. However, as everyone seems to have their own pet CMS, it is sometimes hard for them to understand why anyone would use WordPress for something other than just a blogging platform. I am sure there are many pros and cons, but I will just give my personal answer: I feel very comfortable using and pushing the limits of WordPress for projects because of the huge install and developer base, the active development work being done, the amount of documentation available to my client, and the extensibility and integration my code has with the WordPress core.</p>
<h2>Why WordPress Plugins?</h2>
<p>A WordPress plugin can be a single PHP file or a complex collection of PHP, CSS, JS and images all used together to add new or enhanced functionality to the WordPress core.</p>
<p>Since almost everything you can put in a plugin you can also just dump into a functions.php file in your theme directory, why should you bother building a plugin? Here are a few reasons I find important:</p>
<ul>
<li>Plugins are focused pieces of code structured to accomplish one task. The very nature of a plugin makes it easy to maintain.</li>
<li>Because of the modular nature of a plugin, it makes your code instantly reusable on other projects (Depending on your code ownership agreements with your clients, of course.)</li>
<li>If over time it grows into a truly helpful collection of code, having it in a plugin allows you to release it to the public quickly and easily.</li>
<li>Having large chunks of functionality split into plugins makes changes to the PHP and related files easier to make later.</li>
</ul>
<p>I think WordPress plugins should be especially important to anyone running a web application that could benefit from direct integration into the WordPress platform. This could include a WordPress sidebar widget that pulls information from your website, a shortcode for quickly embedding your site content in WordPress posts, etc.</p>
<p><img src="http://fuelyourcoding.com/files/wordpress_plugins.jpg" alt="wordpress_plugins" title="wordpress_plugins" width="606" height="464" class="aligncenter size-full wp-image-190" /></p>
<h2>Getting Started</h2>
<h3>File Naming</h3>
<p>The first choice you should make is whether you need a single PHP file or a folder with multiple files and assets. Here are some questions help you think through this:</p>
<ul>
<li>Am I going to have associated images, CSS, or JS related to this plugin</li>
<li>Will I have more than one admin panel needed for users to manage this plugin</li>
<li>Will there be multiple distinct pieces to this plugin (i.e. widgets, template tags, etc).</li>
</ul>
<p>If you are building anything more than a simple plugin with a few methods and no associated files, you should go with a directory structure for your plugin.</p>
<p>If we were going to build a plugin called &#8220;Fancy Plugin,&#8221; your file would look like this:</p>
<pre>wp-content/plugins/fancy_plugin.php</pre>
<p>or</p>
<pre>wp-content/plugins/fancy_plugin/fancy_plugin.php</pre>
<p><em>Keep in mind when you name your plugin file that it is unique to what your plugin is and does. Since two plugins cannot both be installed if they have the same file name, be sure to run a Google search and check the <a href="http://wordpress.org/extend/">Extend section of WordPress.org</a> before settling on a name.</em></p>
<h3>Folder Structure</h3>
<p>For complex plugins, I follow this format for my directory structure:</p>
<pre class="brush: plain;">
plugin_folder/
-- plugin_file.php  &lt;= Primary Plugin File
-- css/             &lt;= All CSS
-- images/          &lt;= All Images
-- js/              &lt;= All JS
-- php/             &lt;= Supporting PHP Files
-- views/           &lt;= All Administrative Panels and Metaboxes
</pre>
<h3>Plugin Metadata</h3>
<p>The very first thing you need in your plugin is the metadata block that is used by WordPress to both activate your plugin and notify the user of pertinent information. It should look like this (Taken directly from <a href="http://codex.wordpress.org/Writing_a_Plugin">&#8220;Writing a Plugin&#8221;</a>:</p>
<pre class="brush: php;">&lt;?php
/*
	Plugin Name: Name Of The Plugin
	Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
	Description: A brief description of the Plugin.
	Version: The Plugin's Version Number, e.g.: 1.0
	Author: Name Of The Plugin Author
	Author URI: http://URI_Of_The_Plugin_Author
*/
?&gt;
</pre>
<p>This metadata block is a simple cut and paste into your primary plugin PHP file.</p>
<h2>Extending WordPress With Your Plugin</h2>
<h3>Template Tags</h3>
<p>One of the most simple things your plugin can do, is offer custom template tags for use in your themes. Template tags are just PHP functions. A good rule of thumb is to follow the direction of the WP team by prefixing functions that return data with <strong>get_</strong>, and functions that echo out directly with <strong>the_</strong>. For example:</p>
<pre class="brush: php;">
function get_map_widget_code(){
	return &quot;&lt;script src='...'&gt;My really long widget code...&lt;/script&gt;&quot;;
}

function the_map_widget_code(){
	echo get_map_widget_code();
}
</pre>
<p>These functions could then be used in any theme like this:</p>
<pre class="brush: xml;">
&lt;p&gt;The two ways to use these template tags are echo it myself:&lt;/p&gt;
&lt;?php echo get_map_widget_code() ?&gt;
&lt;p&gt; or let the function echo it (cleaner): &lt;/p&gt;
&lt;?php the_map_widget_code() ?&gt;
</pre>
<p>Template Tags, like all top level functions, have to be unique across the entire set of plugins, WP Core, and theme files. Be sure to choose names that are unique enough as not to conflict with existing method names.</p>
<h3>Shortcodes</h3>
<p>Shortcodes were introduced in WordPress 2.5 and allows the programmer to solve some complex HTML problems in an extremely easy way. Perhaps you want to provide an easy way for a client to list a few products on any page or post. You could just give them the HTML, and tell them to be sure to copy it anywhere they want products&#8230; but we all know how well instructions like those work out. Instead, you should provide a simple short code for them to use:</p>
<pre class="brush: plain;">
[products]
[product name=&quot;My Special Product&quot; price=3.99]
[product name=&quot;An Amazing Book&quot; price=12.99]
[/products]
</pre>
<p>That is a lot easier for a client to remember than a bunch of nested HTML that they have to switch into HTML view to edit or create. Here is the PHP code that would allow this shortcode to function:</p>
<pre class="brush: php;">
function products_shortcode_callback( $atts, $content=null ){
	// Set a blank return by default
	$ret = &quot;&quot;;

	// If there is content between the shortcodes
	// then add our wrapping tags
	if($content){
		$ret = '&lt;ul class=&quot;products in-post-products&quot;&gt;';

		// Nested shortcodes are not processed by default
		// be sure to make this call if you want
		// to process nested shortcodes
		$ret .= do_shortcode($content);

		$ret .= '&lt;/ul&gt;';
	}

	// Never echo output from a shortcode function!!!
	return $ret;
}

function product_shortcode_callback( $atts ){
	// Get the attributes and filter out
	// unwanted attributes
	$a = shortcode_atts( array(
		'name' =&gt; 'Product Name',
		'price' =&gt; 'No Price'), $atts );

	// Prepend a $ sign if price is supplied
	if ($a['price'] != 'No Price') $a['price'] = '$' . $a['price'];

	// Build HTML
	$ret = &quot;&lt;li&gt;&lt;span class='product-name'&gt;&quot;;
	$ret .= $a['name'] . &quot;&lt;/span&gt;&lt;br /&gt;&quot;;
	$ret .= '&lt;span class=&quot;price&quot;&gt;' . $a['price'];
	$ret .= '&lt;/span&gt;&lt;/li&gt;';

	// Again, return NOT echo:
	return $ret;
}

// Finally, add the shortcodes to the system
// So WordPress knows about them
add_shortcode( &quot;products&quot;, &quot;products_shortcode_callback&quot; );
add_shortcode( &quot;product&quot;, &quot;product_shortcode_callback&quot; );
</pre>
<p>As you have seen twice in the comments of the previous code example, <strong>NEVER echo output from a shortcode!</strong> Be sure to always return the content so it can be inserted in the correct place.</p>
<p>The previous code example would replace the shortcodes with this HTML (lines split for clarity):</p>
<pre class="brush: xml;">
&lt;ul class=&quot;products in-post-products&quot;&gt;
&lt;li&gt;&lt;span class=&quot;product-name&quot;&gt;My Special Product&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;price&quot;&gt;$3.99&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;product-name&quot;&gt;An Amazing Book&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;price&quot;&gt;$12.99&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
</pre>
<p><strong>Reference Links</strong></p>
<ul>
<li><a title="WordPress Codex: Shortcode API" href="http://codex.wordpress.org/Shortcode_API">Shortcode API</a></li>
</ul>
<h3>Filters and Actions</h3>
<p>Much of your extensions to the WordPress core will happen with Filters and Actions. Thankfully, they are pretty easy to understand! A filter simply sends you content at the appropriate time, and expects content in return. Be sure to check the documentation on WordPress.org when creating filters because certain filters will pass you more than one parameter. The following code will add text before and after each post title:</p>
<pre class="brush: php;">
function add_text_to_title( $title ){
	return 'Text Before &lt;&lt; ' . $title . ' &gt;&gt; And After';
}
// Register filter with WP
add_filter( &quot;the_title&quot;, &quot;add_text_to_title&quot; );
</pre>
<p>Actions are called when certain actions are about to happen or have just happened. Actions allow you to execute your code at the appropriate time. The following code adds a javascript file to each page of the front-end site:</p>
<pre class="brush: php;">
function add_special_scripts(){
	wp_2_enqueue_script(
		'special_script',
		plugins_url('/test/special.js'),
		array( 'jquery' ), // require jquery
		'0.1' // Helps with cacheing
	);
}
// Register the action with WP
add_action(&quot;wp_2_print_scripts&quot;, &quot;add_special_scripts&quot;);
</pre>
<p><strong>Reference Links</strong></p>
<ul>
<li><a title="WordPress Codex: Plugin API/Action Reference" href="http://codex.wordpress.org/Plugin_API/Action_Reference">Plugin API/Action Reference</a></li>
<li><a title="WordPress Codex: Plugin API/Filter Reference" href="http://codex.wordpress.org/Plugin_API/Filter_Reference">Plugin API/Filter Reference</a></li>
</ul>
<h3>Widgets, Pluggable Functions, Settings, and User Interaction</h3>
<p>Some of the more advanced techniques of building plugins, including user interaction through admin menus, storing settings in the database, and writing a sidebar widget will be covered in an upcoming article.</p>
<h2>Closing Advice</h2>
<ol>
<li>When you begin to extend WordPress through plugins or theme additions, make the <a title="WordPress Codex" href="http://codex.wordpress.org/Main_Page">Codex</a> your best friend. The amount of developer documentation availible is amazing and extremely helpful.</li>
<li>If you cannot find documentation on a particular function or hook, do a global search of your WordPress installation (Cmd+Shift+F in TextMate) to look for the definition of the function. Often looking at the source will give you an idea how it works.</li>
<li>Make sure you have PHP errors turned on locally, or have access to your PHP error log to troubleshoot your development. Not being able to catch small PHP errors can make your life miserable.</li>
</ol>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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-writing-wordpress-plugins/">Getting Started Writing WordPress Plugins</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/getting-started-writing-wordpress-plugins/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Getting to know CakePHP (Part 1)</title>
		<link>http://fuelyourcoding.com/getting-to-know-cakephp-part-1/</link>
		<comments>http://fuelyourcoding.com/getting-to-know-cakephp-part-1/#comments</comments>
		<pubDate>Wed, 20 May 2009 13:34:22 +0000</pubDate>
		<dc:creator>Robin Duckett</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cake]]></category>
		<category><![CDATA[cakephp]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[setup]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=134</guid>
		<description><![CDATA[Welcome to the first of hopefully many articles based on getting to know and love CakePHP.
This article assumes a working knowledge of web development programming in general, including working with Apache, a MySQL database and most obviously, PHP.
CakePHP is a development framework similar to Ruby on Rails, although written in PHP. CakePHP is modelled on [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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-to-know-cakephp-part-1/">Getting to know CakePHP (Part 1)</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Welcome to the first of hopefully many articles based on getting to know and love CakePHP.</p>
<p>This article assumes a working knowledge of web development programming in general, including working with Apache, a MySQL database and most obviously, PHP.</p>
<p>CakePHP is a development framework similar to Ruby on Rails, although written in PHP. CakePHP is modelled on “Convention over Configuration” paradigm, meaning that there should be as little configuration as possible to enable you to very quickly set up a working website. This method of programming is often called RAD (Rapid Application Development).</p>
<p><strong>Important Resources</strong></p>
<ul>
<li> <a href="http://book.cakephp.org/">CakePHP CookBook</a></li>
<li> <a href="http://api.cakephp.org/">CakePHP API Documentation</a></li>
</ul>
<p>Before we grab the source code of Cake (PHP) and get stuck in, let us first find out the requirements.</p>
<p><strong>Required Setup</strong></p>
<ol>
<li><a href="http://www.apache.org/">Apache HTTPD Server</a> (2.0 – 2.2)</li>
<li><a href="http://www.php.net/">PHP</a> (4.x – 5.x)</li>
<li><a href="http://dev.mysql.com/">MySQL</a> (3.x – 5.x)</li>
</ol>
<p>As well as the above, some kind of IDE such as <a href="http://www.gayadesign.com/articles/customize-eclipse-to-a-webdevelopers-ide/">Eclipse PDT</a> or E-Text Editor is also recommended for ease of development. Assuming you have all of these set up correctly, it’s time to grab the source code of Cake from their <a href="http://www.cakephp.org/">most excellent website</a>.</p>
<p>As of writing, the latest stable version of the “Cake Core” is 1.2.3.8166. The large download button shows the way, and the rest is easy. Once downloaded, extract to your configured document root.</p>
<p><img class="aligncenter size-full wp-image-139" title="cake01" src="http://fuelyourcoding.com/files/cake01.png" alt="cake01" width="334" height="326" /></p>
<p>The easiest way to get started, is to create a database using your preferred database management tool (in my case, <a href="http://www.phpmyadmin.net/">phpMyAdmin</a> or you can use <a href="http://dev.mysql.com/workbench/">MySQL Workbench</a>)</p>
<p>For the purposes of this tutorial, I will use a very simple database, the app we will be making is a list of sorts, be it a wish list or a to-do list, whatever you want to do to expand on it will be possible with the help of future tutorials.</p>
<p><strong>Requirements</strong></p>
<ul>
<li>Ability to view a list of “wishes”</li>
<li>Each item should include a link to the particular wish</li>
<li>Each item should be editable to check off whether it has been bought/completed</li>
<li>The list of wishes should order the uncompleted wishes at the top, and the completed wishes at the bottom.</li>
</ul>
<p>A very simple set of requirements makes for a very simple and quickly made application. To start off, let’s create the database.</p>
<p><img class="aligncenter size-full wp-image-142" title="cake02" src="http://fuelyourcoding.com/files/cake02.png" alt="cake02" width="381" height="358" /></p>
<pre class="brush: sql;">
CREATE DATABASE `wishlist`;

CREATE TABLE `wishlist`.`wishes` (
	`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
	`name` VARCHAR( 100 ) NOT NULL ,
	`link` TEXT NOT NULL ,
	`complete` BOOL NOT NULL ,
	`created` DATETIME NOT NULL
) ENGINE = InnoDB;
</pre>
<p>And that’s all there is to creating the database and its table. Notice that the table is named as a plural. This is fundamental to creating tables which CakePHP can understand easily. Also the `created` field is an automagic field, which Cake will automatically populate on creation of a row. ‘modified’ is also another automagic field. Information on field types can be found in the <a href="http://book.cakephp.org/">CookBook</a>.</p>
<h2>Baking your Cake</h2>
<p>Now we’re getting into the technical part. Open a command prompt. If you’re using Linux, I’d expect you to already know how to do this. If you’re using Windows, press the Windows Key and R on your keyboard and type “cmd” without the quotes. In OS X, press Command + Space and type “Terminal” and hit enter.</p>
<p>It should look something like the following in Windows:</p>
<p><img class="aligncenter size-full wp-image-143" title="cake03" src="http://fuelyourcoding.com/files/cake03.png" alt="cake03" width="541" height="335" /></p>
<p>Find the directory you installed Cake Core into, and navigate to the console directory. We are going to use the automatic baking application to create the website at light speed!</p>
<p><img class="aligncenter size-full wp-image-144" title="cake04" src="http://fuelyourcoding.com/files/cake04.png" alt="cake04" width="602" height="432" /></p>
<p>The command that has to be run is “cake bake” as you can see above. This will run the CakePHP Console application. When run with no parameters it will take you through a wizard of sorts. Use this tool to create a new directory somewhere inside your DocumentRoot.</p>
<p>This will dump the default system into the directory, and update its own configuration so it knows where to find the core files.</p>
<p>The next step, it will ask you to specify your database configuration. You can pretty much enter the default values (just hit enter at each option).</p>
<p>When it asks you for the database name, choose “wishlist” or whatever database you chose at the beginning.</p>
<p><img class="aligncenter size-full wp-image-145" title="cake05" src="http://fuelyourcoding.com/files/cake05.png" alt="cake05" width="602" height="432" /></p>
<p>If everything went smoothly, you should end up with the following:</p>
<p><img class="aligncenter size-full wp-image-146" title="cake06" src="http://fuelyourcoding.com/files/cake06.png" alt="cake06" width="602" height="426" /></p>
<p>Follow the on screen instructions for editing the current page and its layouts if you wish.</p>
<p>Now is the time to bake the models and controllers for your system. The easiest way to accomplish this is to use the built-in baking tool once more and create these quickly.</p>
<p><img class="aligncenter size-full wp-image-147" title="cake07" src="http://fuelyourcoding.com/files/cake07.png" alt="cake07" width="602" height="251" /></p>
<p>As we have already set up the Database Configuration, select M first to create the models.</p>
<p><em>Don’t forget to specify –app on the command line in order for the application to know what CakePHP project you are working with.</em></p>
<p><img class="aligncenter size-full wp-image-148" title="cake08" src="http://fuelyourcoding.com/files/cake08.png" alt="cake08" width="602" height="251" /></p>
<p>As you can see, CakePHP has automatically detected our only model and has given it as an option to create a model with. Select ‘y’ so that we can create validation criteria that will be included with the model.</p>
<p>For each field, a screen like the following will be shown, choose the type of the field for each field you have in your table. CakePHP usually does a pretty neat job of automatically choosing for itself, but sometimes it needs a hand.</p>
<p><img class="aligncenter size-full wp-image-149" title="cake09" src="http://fuelyourcoding.com/files/cake09.png" alt="cake09" width="602" height="240" /></p>
<p>In our example, CakePHP does not automatically detect the `link` field as a URL field, nor does it detect the BOOL field `complete` as a Boolean. Select 27 for the `link` field, and 4 for the `complete` field.</p>
<p>Select 8 for the `created` field and you should be all set.</p>
<p>Answer ‘n’ for the model associations question, as there are no other models to associate with in this particular instance.</p>
<p>When your model baking is complete, this is how it should all look:</p>
<p><img class="aligncenter size-full wp-image-150" title="cake10" src="http://fuelyourcoding.com/files/cake10.png" alt="cake10" width="541" height="251" /></p>
<p>Answer ‘n’ again to the testing question. The testing suite is pointless this early in your CakePHP career, but will come in handy once you start getting more advanced.</p>
<p>Next you need to bake your controllers (The actual processing part of your application). Select C on the list:</p>
<p><img class="aligncenter size-full wp-image-151" title="cake11" src="http://fuelyourcoding.com/files/cake11.png" alt="cake11" width="541" height="251" /></p>
<p>The controller section is very easy. You do not need to build your controller interactively, you only need the basic functions, and you do not need to set up admin routing for now.</p>
<p><img class="aligncenter size-full wp-image-152" title="cake12" src="http://fuelyourcoding.com/files/cake12.png" alt="cake12" width="602" height="336" /></p>
<p>Again select ‘n’ for the SimpleTest question and continue.</p>
<p><img class="aligncenter size-full wp-image-153" title="cake13" src="http://fuelyourcoding.com/files/cake13.png" alt="cake13" width="602" height="336" /></p>
<p>As long as you have selected as I have above, you should end up with something similar to this:</p>
<p><img class="aligncenter size-full wp-image-154" title="cake14" src="http://fuelyourcoding.com/files/cake14.png" alt="cake14" width="602" height="426" /></p>
<p>This is the baked index screen, which can be edited in wishlist/views/wishes/index.ctp</p>
<p><img class="aligncenter size-full wp-image-155" title="cake15" src="http://fuelyourcoding.com/files/cake15.png" alt="cake15" width="602" height="426" /></p>
<p>The add wish screen</p>
<p><img class="aligncenter size-full wp-image-156" title="cake16" src="http://fuelyourcoding.com/files/cake16.png" alt="cake16" width="602" height="426" /></p>
<p>The wish index with an item</p>
<p><img class="aligncenter size-full wp-image-157" title="cake17" src="http://fuelyourcoding.com/files/cake17.png" alt="cake17" width="602" height="426" /></p>
<p>A single wish view page</p>
<h2>Conclusion</h2>
<p>CakePHP is incredibly versatile in the way it works, and its configurability. You can literally make a site in a lunch break. The next tutorials will show you how easy it is to customize the app you’ve created today, to finish the remainder of the original requirements of the application, and hopefully bring you a deeper understanding on how good it is to have tasty Cake once in a while.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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-to-know-cakephp-part-1/">Getting to know CakePHP (Part 1)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/getting-to-know-cakephp-part-1/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Steps to becoming a front-end web developer</title>
		<link>http://fuelyourcoding.com/steps-to-becoming-a-front-end-web-developer/</link>
		<comments>http://fuelyourcoding.com/steps-to-becoming-a-front-end-web-developer/#comments</comments>
		<pubDate>Mon, 18 May 2009 23:40:05 +0000</pubDate>
		<dc:creator>Gaya Kessler</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[xhtml / css]]></category>
		<category><![CDATA[become]]></category>
		<category><![CDATA[becoming]]></category>
		<category><![CDATA[front-end]]></category>
		<category><![CDATA[web developer]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=121</guid>
		<description><![CDATA[There are a few things you have to know in order to be a front-end web developer. Where to start and what to learn. This guide will take you through the steps of becoming a front-end web developer.
First things first
Before we start seeing stuff on the screen, we have to make something out of nothing. [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/steps-to-becoming-a-front-end-web-developer/">Steps to becoming a front-end web developer</a></p>
]]></description>
			<content:encoded><![CDATA[<p>There are a few things you have to know in order to be a front-end web developer. Where to start and what to learn. This guide will take you through the steps of becoming a front-end web developer.</p>
<h2>First things first</h2>
<p>Before we start seeing stuff on the screen, we have to make something out of nothing. We start at the basics of web developing: <a href="http://en.wikipedia.org/wiki/HTML">HTML</a>. This markup language will draw shapes on the web page and display text.</p>
<p>HTML is not only very important, your whole markup will depend on it. Don&#8217;t touch CSS yet! We&#8217;ll come to that later.<br />
CSS is worthless with a bad markup supporting it.</p>
<h2>1. Learn HTML</h2>
<ol>
<li><a href="http://www.w3schools.com/html/html_intro.asp">Learn basic HTML</a></li>
<li><a href="http://www.w3schools.com/Xhtml/">Learn about xhtml and validation</a></li>
<li><a href="http://validator.w3.org/">Make valid xhtml and validate</a></li>
</ol>
<p>Learning perfect HTML will take some time but it will really pay off later. It&#8217;s way easier to prevent mistakes and track down bugs when the markup is perfect.</p>
<p>Next step is what you&#8217;ve been waiting for; applying CSS.</p>
<h2>2. Know CSS</h2>
<ol>
<li><a href="http://www.w3.org/Style/Examples/011/firstcss">How to apply CSS</a></li>
<li><a href="http://www.w3schools.com/css/css_background.asp">Know all the important aspects of styling</a></li>
<li><a href="http://css-tricks.com/absolute-relative-fixed-positioining-how-do-they-differ/">Learn about positioning</a></li>
<li><a href="http://www.w3schools.com/css/css_dimension.asp">Get to advanced CSS</a></li>
</ol>
<p>You don&#8217;t have to be perfect at CSS. But being good at it will save a lot of time for your designer.</p>
<p>If you plan on becoming a server side programmer you are best off learning a server side language to generate HTML pages now. Take a look at <a href="http://www.php.net/">PHP</a>, <a href="http://www.asp.net/">ASP.NET</a>, <a href="http://java.sun.com/products/jsp/">JSP</a> etc. if you want to know more.</p>
<p>Now that you know good HTML and CSS it&#8217;s time to put in a little <a href="http://en.wikipedia.org/wiki/JavaScript">Javascript</a>.<br />
Don&#8217;t start by using a framework now, you first need to understand what Javascript is and what it can do to alter the layout of the web page.</p>
<h2>3. Rock Javascript!</h2>
<ol>
<li><a href="http://www.amazon.com/s/ref=nb_ss_b?url=search-alias%3Dstripbooks&amp;field-keywords=javascript&amp;x=0&amp;y=0">Read a good book about Javascript.</a></li>
<li><a href="http://net.tutsplus.com/articles/web-roundups/best-of-the-web-january/">Get to know some funny Javascript effects and concepts.</a> (There are a lot on the Internet)</li>
</ol>
<p>After I read a good book and experimented with Javascript on some projects a bit, I wanted to get everything out of Javascript by making nice effects like the other guys do. For this there are a lot of frameworks available, which also happen to make your Javascript coding a lot easier!</p>
<h2>4. Pick your framework</h2>
<p> </p>
<p>There are a few great Javascript frameworks out there. The biggest players in the game are: <a href="http://mootools.net/">MooTools</a>, <a href="http://jquery.com/">jQuery</a> and <a href="http://script.aculo.us/">script.aculo.us</a>.</p>
<p><a href="http://mootools.net/">MooTools</a> is a lightweight Javascript framework which can be used to utilize simple effects on the elements on your page. It doesn&#8217;t have a lot of fancy features, but it does the job. Good choice for beginners.</p>
<p><a href="http://jquery.com/">jQuery</a> might be the most popular one out there. Not without a reason! It&#8217;s easy to apply, it has great docs, maybe even easier to learn and does a wonderful job. Does require some plugins for extra functionality but it&#8217;s a really nice framework. Also has a large community.</p>
<p><a href="http://script.aculo.us/">script.aculo.us</a> is the mother ship of the Javascript frameworks. It&#8217;s big and weights a ton. It might be a bit slower and requires a bit more programming than its competitors, but it is powerful in what it does. The capabilities of script.aculo.us take a lot up in speed, but for that you get complete control. You can create excellent Rich Internet Applications with this framework.</p>
<p> </p>
<h2>Conclusion</h2>
<p>In just a few step you can become a front-end web developer. This might take a while and it might take some time to get used to a language, but it will pay-off in the end.<br />
There is a lot to be learned on the Internet and it is never too late to try out web development and make the web a little more exciting.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/steps-to-becoming-a-front-end-web-developer/">Steps to becoming a front-end web developer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/steps-to-becoming-a-front-end-web-developer/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Dos and don&#8217;ts of AJAX</title>
		<link>http://fuelyourcoding.com/dos-and-donts-of-ajax/</link>
		<comments>http://fuelyourcoding.com/dos-and-donts-of-ajax/#comments</comments>
		<pubDate>Mon, 04 May 2009 12:05:17 +0000</pubDate>
		<dc:creator>Gaya Kessler</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[backbase]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=46</guid>
		<description><![CDATA[AJAX is one the nicest concept I’ve seen in web development. The basics are simple and quite easy to use.
There are a lot of AJAX frameworks around like jQuery, Prototype and backbase. These frameworks help you create an AJAX application with ease.
But is AJAX really that good? No, but if you use it correctly, it [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/dos-and-donts-of-ajax/">Dos and don&#8217;ts of AJAX</a></p>
]]></description>
			<content:encoded><![CDATA[<p><a onclick="javascript:pageTracker._trackPageview('/outbound/article/en.wikipedia.org');" href="http://en.wikipedia.org/wiki/Ajax_%28programming%29">AJAX</a> is one the nicest concept I’ve seen in web development. The basics are simple and quite easy to use.<br />
There are a lot of <a onclick="javascript:pageTracker._trackPageview('/outbound/article/en.wikipedia.org');" href="http://en.wikipedia.org/wiki/List_of_Ajax_frameworks">AJAX frameworks</a> around like <a onclick="javascript:pageTracker._trackPageview('/outbound/article/jquery.com');" href="http://jquery.com/">jQuery</a>, <a onclick="javascript:pageTracker._trackPageview('/outbound/article/www.prototypejs.org');" href="http://www.prototypejs.org/">Prototype</a> and <a onclick="javascript:pageTracker._trackPageview('/outbound/article/bdn.backbase.com');" href="http://bdn.backbase.com/">backbase</a>. These frameworks help you create an AJAX application with ease.<br />
But is AJAX really that good? No, but if you use it correctly, it is!</p>
<p>In this article I wish to share my view on AJAX and the possibilities it gives to web developers and designers, and why AJAX is wrong in several situations.</p>
<p><img class="alignnone size-full wp-image-49" title="Dos and don'ts of AJAX" src="http://fuelyourcoding.com/files/dodontsajaximg.jpg" alt="Dos and don'ts of AJAX" width="606" height="112" /></p>
<h2>Case 1: Page loading</h2>
<p>What’s up with websites and dynamically loading pages through AJAX? Isn’t it a bit strange that when you want to switch to another page, there is no real page switch?<br />
Sure, I like it when content is loaded into the website dynamically, saving me bandwidth, time and irritation. But a whole page? Isn’t that kind of missing the point?</p>
<ul>
<li>First of all: What about the back and forward buttons of your browser? No use for them if you load a whole page in AJAX.</li>
<li>Second: Funny when a user tries to copy the URL and send it to a friend. Oops, the page is loaded without the content the user expected.</li>
<li>Third: Search Engines can’t pick it up since it is not really a new page.</li>
</ul>
<p>A better way to load content through AJAX is to load only small parts of information on the page. If the users wishes to visit another page, let the browser go to another page.<br />
Loading content in a small part of the page isn’t a bad thing. If you have a container with tabbed content, it’s easy to load the content of other tabs with AJAX, not a problem.</p>
<p>Loading a whole page in AJAX is just overusing the functionality and really missing the point of web browsing.</p>
<h2>Case 2: The content manager</h2>
<p>Being able to adjust the information of your web profile on a web page with the use of AJAX is cool. Fast feedback, fast loading times and convenient. But is it really secure?<br />
I’ve seen sites where the HTTP calls to the server contained the key and value of the part they wanted to configure. Which means the record which will be adjusted is defined. This means you could also change information of other rows in the database. Why? You need to wonder what parts of the profile can be adjusted, and if it applies only to the user who is trying to configure their information, why do you need a key to tell the server which record to adjust?<br />
In PHP, for example, it only takes little effort to remember a value in a session. With this, you know which user is using the website and if you open the session in the AJAX server side pages, you can still read that session. Makes it easy to tell which record to update and doesn’t give a user the opportunity to mess around in your system.</p>
<p>If you do want to send along a key + value, which could be needed in some situations (like inserting a comment), be sure to check the given values in the server side scripts. Can’t say this enough to people, but please be sure the user that is trying to insert / update data has access to that data. This also applies to normal usage of forms, but adjusting an AJAX request is harder for most users. Still it is possible! So be on your guard.</p>
<h2>Case 3: One click update</h2>
<p>This one is something I love about AJAX. The vote buttons on sites, the follow button on Twitter, delete entry buttons and many more of those. The convenience of just clicking once without having to refresh the page is awesome. It’s so simple, yet so powerful.<br />
If you are using such a thing, keep <em>case 2</em> in mind.</p>
<h2>Case 4: Content loading</h2>
<p>One of the most important things of dynamic loading: it has to be quick. Sending a request to a server doesn’t always have to take up most of the time, but loading the response can be a real pain.<br />
Keep the response clean and small. I’ve seen examples (I’ve been guilty in the past) of people giving HTML back in the response. With this they’ll adjust the innerHTML of a container. In the worst case they’ll load a whole new page (like in <em>case 1</em>).</p>
<p>To solve this, please use <a onclick="javascript:pageTracker._trackPageview('/outbound/article/www.php.net');" href="http://www.php.net/json_encode">JSON</a> or anything of that kind. JSON helps you convert server side variables to Javascript variables. The response the server will give are Javascript variables for Javascript to read. JSON has been implemented in PHP since version 5.2.0 and is easy to use.</p>
<p>Don’t give HTML back to your web page, but arrays of information. This helps keeping the presentation of your site and the calculation apart from each other. Do the adjusting of the DOM in Javascript.</p>
<h2>Case 5: External Services</h2>
<p>When you use external services and feeds to build a web page in server side scripting, you rely on an external service. This can also result is pages loading slower than needed. The is why AJAX is ideal for loading external services.</p>
<p>Load information from an external source after loading the page. This will prevent slow loading of the rest of the page and let’s the information just easily slip in the page when it’s ready.</p>
<h2>Conclusion</h2>
<p>I hope I’ve given my point of view on AJAX and how to use it. If you wish to discuss the things that I’ve said; please do so!</p>
<p>Share your AJAX stories with me =)</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/dos-and-donts-of-ajax/">Dos and don&#8217;ts of AJAX</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/dos-and-donts-of-ajax/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Reading XML with PHP</title>
		<link>http://fuelyourcoding.com/reading-xml-with-php/</link>
		<comments>http://fuelyourcoding.com/reading-xml-with-php/#comments</comments>
		<pubDate>Mon, 04 May 2009 11:03:00 +0000</pubDate>
		<dc:creator>Gaya Kessler</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[last.fm]]></category>
		<category><![CDATA[read]]></category>
		<category><![CDATA[read xml]]></category>
		<category><![CDATA[simplexml]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://fuelyourcoding.com/?p=37</guid>
		<description><![CDATA[Since webservices and RESTful services are becoming more and more popular, XML is getting a common format to exchange information. XML is easy to read and has a nice tree structure, which can be easily interpreted.
This post will show you how easy it is to read XML in PHP.

In this tutorial I’ll teach you how [...]<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/reading-xml-with-php/">Reading XML with PHP</a></p>
]]></description>
			<content:encoded><![CDATA[<p>Since webservices and RESTful services are becoming more and more popular, XML is getting a common format to exchange information. XML is easy to read and has a nice tree structure, which can be easily interpreted.</p>
<p>This post will show you how easy it is to read XML in PHP.</p>
<p><img class="alignnone size-full wp-image-38" title="Reading XML with PHP" src="http://fuelyourcoding.com/files/readxmlphpimg.jpg" alt="Reading XML with PHP" width="609" height="185" /></p>
<p>In this tutorial I’ll teach you how to read information which a simple webservice provides. The webservice I choose is <a onclick="javascript:pageTracker._trackPageview('/outbound/article/www.last.fm');" href="http://www.last.fm/api">Last.fm</a>. It’s quick, fun and has a lot of features. We’ll use the <strong>Recent Tracks</strong> information of a user profile.</p>
<p>According to the <a onclick="javascript:pageTracker._trackPageview('/outbound/article/www.last.fm');" href="http://www.last.fm/api/">API of Last.fm</a> the XML which will be returned will look something like this:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;lfm status=&quot;ok&quot;&gt;
	&lt;recenttracks user=&quot;xgayax&quot;&gt;

		&lt;track nowplaying=&quot;true&quot;&gt;
			&lt;artist mbid=&quot;1bc41dff-5397-4c53-bb50-469d2c277197&quot;&gt;The Dillinger Escape Plan&lt;/artist&gt;
			&lt;name&gt;Party Smasher&lt;/name&gt;
			&lt;streamable&gt;1&lt;/streamable&gt;
			&lt;mbid&gt;&lt;/mbid&gt;
			&lt;album mbid=&quot;&quot;&gt;Ire Works&lt;/album&gt;
			&lt;url&gt;http://www.last.fm/music/The+Dillinger+Escape+Plan/_/Party+Smasher&lt;/url&gt;
			&lt;image size=&quot;small&quot;&gt;http://userserve-ak.last.fm/serve/34s/19117171.jpg&lt;/image&gt;
			&lt;image size=&quot;medium&quot;&gt;http://userserve-ak.last.fm/serve/64s/19117171.jpg&lt;/image&gt;
			&lt;image size=&quot;large&quot;&gt;http://userserve-ak.last.fm/serve/126/19117171.jpg&lt;/image&gt;
			&lt;date uts=&quot;1230497786&quot;&gt;28 Dec 2008, 20:56&lt;/date&gt;
		&lt;/track&gt;

		...

	&lt;/recenttracks&gt;
&lt;/lfm&gt;
</pre>
<p>This is a part of the actual XML Last.fm gave me. We can see that is not too complicated, which is a good thing!</p>
<p>So what do we need to do now? First, we need that XML file in PHP. We can accomplish that by using the <strong>simplexml_load_file</strong> function in PHP <em>(Introduced with PHP5)</em>.</p>
<p>It only needs the URI to the XML file and it will convert the string into an XML object. Pretty neat.</p>
<p>Create a new PHP file and place this code somewhere:</p>
<pre class="brush: php;">
$completeurl =
&quot;http://ws.audioscrobbler.com/2.0/?method=&amp;user=xgayax&quot; .
&quot;&amp;api_key=b25b959554ed76058ac220b7b2e0a026&quot;;
$xml = simplexml_load_file($completeurl);
</pre>
<p>This will load the given file into an object. The url can be adjusted to your needs, preferably the API key since I borrowed it from the Last.fm site.</p>
<p>All what’s left for us to do is to loop through the given object.</p>
<p>Take a look at the following code:</p>
<pre class="brush: php;">
$tracks = $xml-&gt;recenttracks-&gt;track;

for ($i = 0; $i &lt; 3; $i++) {
	$nowplaying = $tracks[$i]-&gt;attributes()-&gt;nowplaying;
	$trackname = $tracks[$i]-&gt;name;
	$artist = $tracks[$i]-&gt;artist;
	$url = $tracks[$i]-&gt;url;
	$date = $tracks[$i]-&gt;date;
	$img = $tracks[$i]-&gt;children();
	$img = $img-&gt;image[0];

	echo &quot;&lt;a href='&quot; . $url . &quot;' target='TOP'&gt;&quot;;

	if ($nowplaying == &quot;true&quot;) {
		echo &quot;Now playing: &quot;;
	}

	echo &quot;&lt;img src='&quot; . $img . &quot;' alt='album' /&gt;
	$artist . &quot; - &quot; . $trackname . &quot; @ &quot; . $date . &quot;
	&lt;/a&gt;
	&quot;;
}
</pre>
<p>To understand what is happening, I’ll explain some of the actions I did to get the right information.</p>
<p>Going through the XML tree is easy.<strong> $xml</strong> will refer to the root element, which is <strong>&lt;lfm&gt;</strong> in this case. From this element we can navigate through the XML tree.<br />
If you want: <strong>&lt;lfm&gt;&lt;recenttracks&gt;&lt;track&gt;</strong> you’ll get <strong>$xml-&gt;recenttracks-&gt;track</strong> in PHP. And because <strong>recenttracks </strong>contains multiple <strong>tracks</strong> an array will be given.</p>
<p>The size of the loop is limited to 3, you can however replace this with <strong>sizeof($tracks)</strong> is you please.</p>
<p>Just like explained above, getting the information inside a tag is done like this: <strong>$tracks[$i]-&gt;tagname</strong>. You’ll get the text which is inside (if it contains text, or else you’ll get an object or an empty string.)</p>
<p>To read attribute information, you need to use the <strong>attributes()</strong> method. Like I did in this line: <strong>$tracks[$i]-&gt;attributes()-&gt;nowplaying</strong>. If the attribute doesn’t exist you’ll get an empty string.</p>
<p>I hope this gets you into reading XML’s using PHP. It is easy and takes little time to learn.<br />
I’ve used XML reading for serveral purposes now like synchronizing information with a database and displaying upcoming event information.</p>
<p>The power of XML is now in your hands.</p>
<p><p><strong>Sponsored by</strong></p>
<a href='http://madebytinder.com' target='_blank'><img src='http://fuelbrand.s3.amazonaws.com/downloads/WhatisTinder250x250.jpg' border='0' alt='Made By Tinder' /></a>
<p><a href="http://www.fuelbrandnetwork.com/advertise/">Advertise on Fuel Brand Network</a>. <br />
  <a href="http://www.fuelbrandnetwork.com">Fuel Brand Network</a> 2010 <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/reading-xml-with-php/">Reading XML with PHP</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fuelyourcoding.com/reading-xml-with-php/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
